点击next图片没反应

来源:3-1 箭头切换

假装自己是全栈

2018-09-01 01:36

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            text-decoration: none;
        }
        
        body {
            padding: 20px;
        }
        
        #container {
            width: 600px;
            height: 400px;
            border: 1px solid #333;
            position: relative;
            overflow: hidden;
        }
        
        #list {
            width: 3600px;
            height: 400px;
            position: absolute;
            z-index: 1;
        }
        
        #list img {
            float: left;
        }
        
        #buttons {
            width: 100px;
            height: 10px;
            position: absolute;
            bottom: 15px;
            left: 250px;
            z-index: 2;
        }
        
        #buttons span {
            width: 10px;
            height: 10px;
            border: 1px solid #FFFFFF;
            margin: 0 5px;
            border-radius: 50px;
            float: left;
            cursor: pointer;
        }
        
        #buttons .on {
            background: #FFFFFF;
        }
        
        .arrow {
            width: 40px;
            height: 40px;
            line-height: 39px;
            text-align: center;
            background: rgba(0, 0, 0, .3);
            display: none;
            position: absolute;
            top: 180px;
            z-index: 2;
            cursor: pointer;
            font-size: 25px;
            color: #FFFFFF;
        }
        
        .arrow:hover {
            background: rgba(0, 0, 0, .7);
        }
        
        #container:hover .arrow {
            display: block;
        }
        
        #prev {
            left: 20px;
        }
        
        #next {
            right: 20px;
        }
    </style>
    <script>
 window.onload = function () {
            var container = document.getElementById('container');
            var list = document.getElementById('list');
            var buttons = document.getElementById('buttons').getElementsByTagName('span');
            var next = document.getElementById('next');
            var prev = document.getElementById('prev');


            next.onclick = function () {
                list.style.left = parseInt(list.style.left) - 600 + 'px';
            }
        };
    </script>
</head>
<body>
<div id="container">
    <div id="list" style="left: -600px;">
        <img src="img/banner-4.jpeg" alt="">
        <img src="img/banner-1.jpeg" alt="">
        <img src="img/banner-2.jpg" alt="">
        <img src="img/banner-3.jpg" alt="">
        <img src="img/banner-4.jpeg" alt="">
        <img src="img/banner-1.jpeg" alt="">
    </div>
    <div id="buttons">
        <span index="1" class="on"></span>
        <span index="2"></span>
        <span index="3"></span>
        <span index="4"></span>
    </div>
    <a href="" class="arrow" id="prev">&lt</a>
    <a href="" class="arrow" id="next">&gt</a>
</div>
</body>
</html>


写回答 关注

1回答

  • 慕仰9764282
    2018-09-01 15:22:11

    <a href="javascript:;" class="arrow" id="prev">&lt</a>    

    <a href="javascript:;" class="arrow" id="next">&gt</a>

焦点图轮播特效

通过本教程学习您将能掌握非常实用的焦点图轮播特效的制作过程

65234 学习 · 611 问题

查看课程

相似问题