dmz社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 821|回复: 0

[Html/Css] 层级轮播图

[复制链接]
  • TA的每日心情

    2024-2-20 11:15
  • 签到天数: 11 天

    [LV.3]偶尔看看II

    878

    主题

    4343

    帖子

    3995

    积分

    终身会员[A]

    Rank: 7Rank: 7Rank: 7

    积分
    3995

    发表于 2020-4-13 10:00:01 | 显示全部楼层 |阅读模式

    本站资源全部免费,回复即可查看下载地址!

    您需要 登录 才可以下载或查看,没有帐号?立即注册

    x
    css
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }

        ul, ol {
            list-style: none;
        }

        .wrap {
            width: 650px;
            height: 250px;
            margin: 100px auto 0;
            position: relative;
            overflow: hidden;
        }

        .wrap img {
            display: block;
        }

        .wrap ul {
            height: 250px;
            z-index: 1;
            position: relative;
        }

        .wrap ol {
            height: 30px;
            z-index: 2;
            position: absolute;
            bottom: 0;
            right: 0;
        }

        .wrap > ul > li {
            position: absolute;
            top: 0;
            left: 650px;
        }

        .wrap > ol > li {
            float: left;
            width: 20px;
            height: 20px;
            text-align: center;
            line-height: 20px;
            border: 1px solid white;
            margin-right: 5px;
            background: Gray;
        }

        .wrap > ol > li:hover {
            cursor: pointer;
        }

        .wrap li.active {
            padding: 2px;
            color: orange;
            margin-top: -4px;
            border: 1px solid orange;
        }
    </style>


    html、js
    [HTML] 纯文本查看 复制代码
    <div class="wrap">
        <ul>
            <li style="z-index:0;left:0;"><img src="images/01.jpg" alt=""/></li>
            <li><img src="images/02.jpg" alt=""/></li>
            <li><img src="images/03.jpg" alt=""/></li>
            <li><img src="images/04.jpg" alt=""/></li>
            <li><img src="images/05.jpg" alt=""/></li>
        </ul>
        <ol>
            <li class="active">1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
            <li>5</li>
        </ol>
    </div>
     
    <script type="text/javascript">
       var timer = null;
        var index = 0;
        var $olist = $("ol li");
        var $ulist = $("ul li");
        timer = setInterval( autoPlay , 3000 );
        function autoPlay(){
            index++;
            if( index == $olist.size() ){
                index = 0;
            }
            $olist.eq(index).addClass("active").siblings().removeClass("active");
            $ulist.eq(index).animate({"left":0},1500,function(){
                //当前运动的图片达到目标值后  将其余所有的图片恢复到left:650位置
                 $(this).css("zIndex",0).siblings().css({"left":650,"zIndex":1})
            })
        }
    </script>








    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|小黑屋|本站代理|dmz社区

    GMT+8, 2025-2-2 04:47 , Processed in 0.217492 second(s), 29 queries .

    Powered by Discuz! X3.4 Licensed

    Copyright © 2001-2021, Tencent Cloud.

    快速回复 返回顶部 返回列表