zoukankan      html  css  js  c++  java
  • jQuery实际案例④——360导航图片效果

    如图:①首先使用弹性盒子布局display:flex; flex-wrap:wrap; ②鼠标移上去出现“百度一下,你就知道了”,这句话之前带上各个网站的logo;③logo使用的是sprite,需要注意的是background-position使用的是负值(-)

    整体代码如下:

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>09 360导航图片效果</title>
    <style>
    *{ margin: 0; padding: 0; list-style: none; }
    .wrap{
    margin: 50px auto;
    padding: 10px 0 0 10px;
    752px;
    border: 1px solid #ccc;
    font-family: arial;
    }
    ul{
    display: flex;
    flex-flow: wrap;
    }
    ul li{
    position: relative;
    margin: 0 10px 10px 0;
    178px;
    height: 125px;
    overflow: hidden;
    }
    .wrap li div,.wrap li p{
    position: absolute;
    left: 0;
    bottom: -25px;
    _bottom: -26px;
    100%;
    height: 25px;
    line-height: 25px;
    text-align: center;
    color: #fff;
    font-size: 14px;
    }
    .wrap li div{
    background-color: rgba(0, 0, 0, 0.5);
    }
    .wrap li p{
    padding-left: 5px;
    background: url('images/bg.png') no-repeat 5px 0;
    }
    </style>
    <script src="jquery-1.11.1.min.js"></script>
    <script>
    $(document).ready(function() {
    var div = $("<div></div>"), speed = 388, $p = $(".wrap p");
    $p.before(div);
    $(".wrap div").fadeTo(0,0.5);
    $p.each(function(index, el) {
    $(el).css("background-position","5px -"+(index*25)+"px");
    });
    $("li").hover(function() {
    $(this).children('div,p').stop().animate({"bottom":0},speed);
    }, function() {
    $(this).children('div,p').stop().animate({"bottom":"-25px"},speed);
    });
    });
    </script>
    </head>
    <body>
    <div class="wrap">
    <ul>
    <li><a href="#"><img src="images/01.JPG" alt=""></a><p>百度一下,你就知道啦</p></li>
    <li><a href="#"><img src="images/02.JPG" alt=""></a><p>百度一下,你就知道啦</p></li>
    <li><a href="#"><img src="images/03.JPG" alt=""></a><p>百度一下,你就知道啦</p></li>
    <li><a href="#"><img src="images/04.JPG" alt=""></a><p>百度一下,你就知道啦</p></li>
    <li><a href="#"><img src="images/05.JPG" alt=""></a><p>百度一下,你就知道啦</p></li>
    <li><a href="#"><img src="images/06.JPG" alt=""></a><p>百度一下,你就知道啦</p></li>
    <li><a href="#"><img src="images/07.JPG" alt=""></a><p>百度一下,你就知道啦</p></li>
    <li><a href="#"><img src="images/08.JPG" alt=""></a><p>百度一下,你就知道啦</p></li>
    </ul>
    </div>
    </body>
    </html>

  • 相关阅读:
    python学习笔记—— 函数
    python学习笔记——异常
    javascript 本地数据库例子
    python学习笔记——web.py
    远程桌面连接的安装和设置
    word中如何设置页码从任意页开始
    Payoneer取人民币全过程(ATM)
    菜鸟学习四种制作Word自动生成目录的方法!
    如何设置Windows 7远程桌面连接
    Freelancer:全球最大自由职业者线上市场是如何养成的
  • 原文地址:https://www.cnblogs.com/carriezhao/p/7090783.html
Copyright © 2011-2022 走看看