博主信息
博文 41
粉丝 0
评论 1
访问量 41572
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
jq手风琴
kong
原创
1618人浏览过

思路:

    鼠标进入每一个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>




本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学