为了账号安全,请及时绑定邮箱和手机立即绑定

点击左右箭头到第7张图片出现空白?left值无限的增加减少。我的width:770

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Document</title>

<style>

*{

margin: 0;

padding: 0;

text-decoration: none;

}


body{

padding: 20px;

}


#container{

width: 770px;

height: 365px;

border: 3px solid #333;

overflow: hidden;

position: relative;

}


#list{

width: 3850px;

height: 365px;

position: absolute;

z-index: 1;

}


#list img{

float: left;

}


#buttons{

position: absolute;

height: 10px;

width: 100px;

z-index: 2;

bottom: 20px;

left: 350px;

}


#buttons span{

cursor: pointer;

float: left;

border: 1px solid #fff;

width: 10px;

height: 10px;

border-radius: 50%;

background: #333;

margin-right: 8px; 

}


#buttons .on{

background: orangered;

}


.arrow{

cursor: pointer;

display: none;

line-height: 70px;

text-align: center;

color: #fff;

font-size: 30px;

font-weight: bold;

width: 30px;

height: 75px;

position: absolute;

z-index: 2;

top: 180px;

background: #A5A3A1;

margin-top: -25px;

opacity: .6;

}


.arrow:hover{

background-color: #7F7E7E;

opacity: .3;

}


#container:hover .arrow{

display: block;

}


#prev{

left: 2px;

}

#next{

right: 2px;

}

</style>

</head>

<body>

<div id="container">

    <div id="list" style="left: -770px;">

        <img src="images/5.jpg" alt=""/>

        <img src="images/1.jpg" alt=""/>

        <img src="images/2.jpg" alt=""/>

        <img src="images/3.jpg" alt=""/>

        <img src="images/4.png" alt=""/>

        <img src="images/5.jpg" alt=""/>

        <img src="images/1.jpg" alt=""/>

    </div>

    <div id="buttons">

        <span index="1" class="on"></span>

        <span index="2"></span>

        <span index="3"></span>

        <span index="4"></span>

        <span index="5"></span>

    </div>

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

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

</div>


<script>

window.onload = function () {

var container = document.getElementById('container');

var list = document.getElementById('list');

var buttons = document.getElementById('buttons').getElementsByTagName('span');

var prev = document.getElementById('prev');

var next = document.getElementById('next');


function ainimet(offtset){

list.style.left = parseInt(list.style.left) + offtset + 'px';

}

next.onclick = function () {

ainimet(-770);

}

prev.onclick = function () {

ainimet(770);

}

}

</script>

</body>

</html>

直接拿sublime运行

正在回答

2 回答

弄好了,谢谢。原来是没写完的!

0 回复 有任何疑惑可以回复我~
#1

慕粉3782992

我也出现这种情况了,请问怎么解决
2017-04-29 回复 有任何疑惑可以回复我~

你连代码都不贴的吗╮(╯▽╰)╭

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

点击左右箭头到第7张图片出现空白?left值无限的增加减少。我的width:770

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信