JavaScript 原生态幻灯片切换

<!doctype html>
<html>
<head>
    <title>
        幻灯片效果联系
    </title>

    <style type="text/css">
        body{background-color: #373737;}
        body, ul, li, a, img{margin: 0px; padding: 0px;}
        .box{width: 600px; height: 400px; background-color: #FFFFFF; margin: 0px auto; position: relative;  overflow: hidden;}
        .box #ImgBox{width: 1200px; height: 400px; position: absolute; left: 0px; top: 0px;}
        .box #ImgBox ul{}
        .box #ImgBox li{float: left; list-style-type: none;}
        .box #ImgBox img{width: 600px; height: 400px; display: block;}
        .box .ImgNum{position: absolute; left: 0px; bottom: 10px; width: 100%; text-align: center;}
        .box .ImgNum a{width: 20px; height: 5px; background-color: #FFFFFF; overflow: hidden; display: inline-block; margin: 0px 2px;}
        .box .ImgNum .active{background-color: #FF7700;}
    </style>

    <script type="text/javascript">
        function move(num)
        {
            var p1 = document.getElementById("p1");
            var p2 = document.getElementById("p2");
            if(num == 1)
            {
                document.getElementById("ImgBox").style.left = "0px";
                p2.setAttribute("class", "");
                p1.setAttribute("class", "active");
            }
            else
            {
                document.getElementById("ImgBox").style.left = "-600px";
                p1.setAttribute("class", "");
                p2.setAttribute("class", "active");
            }
        }
    </script>
</head>

<body>
    <div class="box">
        <ul id="ImgBox">
            <li><a href="#"><img src="banner_01.jpg" /></a></li>
            <li><a href="#"><img src="banner_02.jpg" /></a></li>
        </ul>
        <ul class="ImgNum">
            <a id="p1" class="active" href="#" οnmοuseοver="move(1)"></a>
            <a id="p2" href="#" οnmοuseοver="move(-1)"></a>
        </ul>
    </div>
</body>
</html>

转载于:https://my.oschina.net/u/1468096/blog/335397

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值