CSS+JS网页制作实例:新闻列表鼠标滑过显示详情

2013-04-18 09:13:56  来源:网页教学网 

网页制作Webjx文章简介:新闻列表鼠标滑过,显示单条详情.

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>demo</title>
<style type="text/css">
body { font-size:12px; }
ul, h2, p { margin:0; padding:0; }
.list { list-style:none; width:400px; position:relative; vertical-align:middle; }
.list li { border-bottom:solid 1px #eee; cursor:default; position:relative; width:100%; }
.list h2 { font-size:100%; font-weight:normal; padding:.5em;}
.list span { position:absolute; right:1em; top:.5em; font-family:Verdana; font-size:90%;}
.list div { display:none; position:relative; height:70px; }
.list div img { float:left; margin:.8em 1em; background:#6FF; }
.list div p { padding:.8em; font-size:11px;}
.list div p strong { display:block; margin-bottom:.5em; }
.list li:hover, .list li.hover { height:auto; }
.list li:hover div, .list li.hover div { display:block; }
.list li:hover h2, .list li.hover h2, .list li:hover span, .list li.hover span { background:#5B86BB; color:#fff; }
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
</head>
<body>
<ul class="list" id="demo">
  <li>
    <h2>酷玩族手机</h2>
    <span>2013-03-15</span>
    <div> <img src="http://www.webjx.com/images/logo.gif" alt="" width="100" height="50" />
      <p><strong>酷玩族手机</strong>IOS6.1完美越狱-安卓软件园-android手机平板安卓软件下载-安卓rom刷机教程-ROM固件包下载-游戏下载-主题壁纸下载</p>
    </div>
  </li>
  <li>
    <h2>酷玩族手机</h2>
    <span>2013-03-15</span>
    <div> <img src="http://www.webjx.com/images/logo.gif" alt="" width="100" height="50" />
      <p><strong>酷玩族手机</strong>IOS6.1完美越狱-安卓软件园-android手机平板安卓软件下载-安卓rom刷机教程-ROM固件包下载-游戏下载-主题壁纸下载</p>
    </div>
  </li>
  <li>
    <h2>酷玩族手机</h2>
    <span>2013-03-15</span>
    <div> <img src="http://www.webjx.com/images/logo.gif" alt="" width="100" height="50" />
      <p><strong>酷玩族手机</strong>IOS6.1完美越狱-安卓软件园-android手机平板安卓软件下载-安卓rom刷机教程-ROM固件包下载-游戏下载-主题壁纸下载</p>
    </div>
  </li>
  <li>
    <h2>酷玩族手机</h2>
    <span>2013-03-15</span>
    <div> <img src="http://www.webjx.com/images/logo.gif" alt="" width="100" height="50" />
      <p><strong>酷玩族手机</strong>IOS6.1完美越狱-安卓软件园-android手机平板安卓软件下载-安卓rom刷机教程-ROM固件包下载-游戏下载-主题壁纸下载</p>
    </div>
  </li>
  <li>
    <h2>酷玩族手机</h2>
    <span>2013-03-15</span>
    <div> <img src="http://www.webjx.com/images/logo.gif" alt="" width="100" height="50" />
      <p><strong>酷玩族手机</strong>IOS6.1完美越狱-安卓软件园-android手机平板安卓软件下载-安卓rom刷机教程-ROM固件包下载-游戏下载-主题壁纸下载</p>
    </div>
  </li>
  <li>
    <h2>酷玩族手机</h2>
    <span>2013-03-15</span>
    <div> <img src="http://www.webjx.com/images/logo.gif" alt="" width="100" height="50" />
      <p><strong>酷玩族手机</strong>IOS6.1完美越狱-安卓软件园-android手机平板安卓软件下载-安卓rom刷机教程-ROM固件包下载-游戏下载-主题壁纸下载</p>
    </div>
  </li>
  <li>
    <h2>酷玩族手机</h2>
    <span>2013-03-15</span>
    <div> <img src="http://www.webjx.com/images/logo.gif" alt="" width="100" height="50" />
      <p><strong>酷玩族手机</strong>IOS6.1完美越狱-安卓软件园-android手机平板安卓软件下载-安卓rom刷机教程-ROM固件包下载-游戏下载-主题壁纸下载</p>
    </div>
  </li>
</ul>
<script type="text/javascript">
$(function() {
    if ($('#demo li').length > 0) {
        $('#demo li').eq(0).addClass('hover');
        $('#demo li').mouseenter(function() {
            $(this).siblings('.hover').removeClass('hover').end().addClass('hover');
        });
    }
});
</script>
</body>
</html>

更多