论坛首页 Web前端技术论坛

一个很简单的基于css的图片切换效果

浏览 4139 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2009-10-31   最后修改:2010-12-01
CSS

一个基于css的图片切换效果,很简单,鼠标点击后可以显示当前图片。

 dl {
    position:absolute;
    width:240px;
    height:170px;
    border:10px solid #eee;
  }
  dd {
    margin:0;
    width:240px;
    height:170px;
    overflow:hidden;
  }
  img {
    border:1px solid black
  }
  dt {
    position:absolute;
    right:3px;
    top:50px;
  }
  a {
    display:block;
    margin:1px;
    width:20px;
    height:20px;
    text-align:center;
    font:700 12px/20px "宋体",sans-serif;
    color:#fff;
    text-decoration:none;
    background:#666;
    border:1px solid #fff;
    filter:alpha(opacity=40);
    opacity:.4;
  }
  a:hover {
    background:#000
  }

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="/swap/stylesheets/swap.css" rel="stylesheet" type="text/css" />
  </head>
  <body>
    <dl>
      <dt><a href="#a">1</a><a href="#b">2</a><a href="#c">3</a></dt>
      <dd>
        <img src="/swap/images/1.jpg" id="a" />
        <img src="/swap/images/2.jpg" id="b" />
        <img src="/swap/images/3.jpg" id="c" />
      </dd>
    </dl>
  </body>
 </html>

 

论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics