博客列表 >jq手风琴

jq手风琴

kong
kong原创
2018年04月21日 23:12:001356浏览

思路:

    鼠标进入每一个li,做相应操作,li本身变宽560,其他li变成60,当前li里的span(遮罩)淡出,其他的淡入


效果:

1.gif.gif.gif

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>手风琴</title>
</head>
<body>
<style>
     *{
      padding: 0;
      margin: 0;
     }
     ul{
      list-style-type: none;
      padding: 0;
      margin: 0;
     }
     .red{
      background: red;
     }
     .blue{
      background: blue;
     }
     .yellow{
      background: yellow;
     }
     .box{
      width: 800px;
      margin: 0 auto;
      overflow: hidden;
     }
     .box ul{
      overflow: hidden;
      width: 2000px;
     }
     .box ul li{
      width: 160px;
      height: 300px;
      float: left;
      position: relative;
     }

.box ul li.last{
width: 560px;
}

     .box ul li span{
      position: absolute;
      width: 100%;
      height: 100%;
      background: #000;
      opacity: 0.6;
      filter: alpha(opacity=60);
      top: 0;
      left: 0;
     }


</style>
<div>
<ul>
<li>
<span></span>
<img src="images/0.jpg" alt="">
</li>
<li>
<span></span>
<img src="images/1.jpg" alt="">
</li>
<li>
<span></span>
<img src="images/2.jpg" alt="">
</li>
<li>
<span></span>
<img src="images/3.jpg" alt="">
</li>
<li>
<span></span>
<img src="images/4.jpg" alt="">
</li>
</ul>
</div>
<script src="jquery.min.js"></script>
<script>
var during = 500;
     $(".box li").each(function(){
      $(this).mouseenter(function(event) {
      /* Act on the event */
      $(this).stop(true).animate({
      "width": 560
      },during).siblings().stop(true).animate({
      "width": 60
      }, during);
      $(this).children('span').stop(true).fadeOut(during);
      $(this).siblings().children('span').stop(true).fadeIn(during);

      });
     });
     $(".box").mouseleave(function(event) {
      /* Act on the event */
      $(this).find('li').stop(true).animate({
      "width": 160
      },during);
      $(this).find("span").stop(true).fadeIn(during);
     });
</script>
</body>
</html>




上一条:端口下一条:第三章:1.变量的运算
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议