找了好久也不知道哪里錯(cuò)了,滾動(dòng)也實(shí)行不了
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>無(wú)標(biāo)題文檔</title><style type="text/css">
? *{ margin: 0; padding: 0; text-decoration: none;}
? ? ? ? body { padding: 20px;}
? ? ? ? #container { width: 600px; height: 400px; border: 3px solid #333; overflow: hidden; position: relative;}
? ? ? ? #list { width: 4200px; height: 400px; position: absolute; z-index: 1;}
? ? ? ? #list img { float: left;}
? ? ? ? #buttons { position: absolute; height: 10px; width: 100px; z-index: 2; bottom: 20px; left: 250px;}
? ? ? ? #buttons span { cursor: pointer; float: left; border: 1px solid #fff; width: 10px; height: 10px; border-radius: 50%; background: #333; margin-right: 5px;}
? ? ? ? #buttons .on { ?background: orangered;}
? ? ? ? .arrow { cursor: pointer; display: none; line-height: 39px; text-align: center; font-size: 36px; font-weight: bold; width: 40px; height: 40px; ?position: absolute; z-index: 2; top: 180px; background-color: RGBA(0,0,0,.3); color: #fff;}
? ? ? ? .arrow:hover { background-color: RGBA(0,0,0,.7);}
? ? ? ? #container:hover .arrow { display: block;}
? ? ? ? #prev { left: 20px;}
? ? ? ? #next { right: 20px;}
</style>
<script type="text/javascript">
? ? ? ? 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');
? ? ? ? ? ? var index = 1;
?function showButton() {
? ? ? ? ? ? ? ? for (var i = 0; i < buttons.length ; i++) {
? ? ? ? ? ? ? ? ? ? if( buttons[i].className == 'on'){
? ? ? ? ? ? ? ? ? ? ? ? buttons[i].className = '';
? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? buttons[index - 1].className = 'on';
? ? ? ? ? ? }
function animate(offset){
var newLeft=parseInt(list.style.left)+offset;
list.style.left=newLeft+'px';
if(newLeft>-600){list.style.left=-3000+'px';
}
if(newLeft<-3000){list.style.left=-600+'px';}
}
next.onclick = function () { if (index == 5) {
? ? ? ? ? ? ? ? ? ? index = 1;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? else {
? ? ? ? ? ? ? ? ? ? index += 1;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? animate(-600);
? ? ? ? ? ? ? ? showButton();
? ? ? ? ? ? }
prev.onclick = function () {
?
? if (index == 1) {
? ? ? ? ? ? ? ? ? ? index = 5;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? else {
? ? ? ? ? ? ? ? ? ? index -= 1;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? animate(600);
? ? ? ? ? ? ? ? showButton();
? ? ? ? ? ? }
</script>
? ??
</head>
<body>
<div id="container">
? ? <div id="list" style="left: -600px;">
? ? ? ? <img src="images/0.jpg" alt="1"/>
? ? ? ? <img src="images/4354_27d6d4fb6-61be-4a56-b046-8c4c90c707d7.png" alt="1"/>
? ? ? ?<img src="images/294422825739568090_.jpg" ?alt="2"/>
? ? ? ?<img src="images/mzl.tsrvdtee.175x175-75.png" alt="3"/>
? ? ? ? <img src="images/u=493782737,3064530006&fm=21&gp=0.jpg" alt="4"/>
? ? ? ? <img src="images/u=1602452522,2035743143&fm=21&gp=0.jpg" ?alt="5"/>
? ? ? ?<img src="images/c1bca6a39e4f2637-e6da0b2b85c0cc73-bf2de4416304fd7b757f118a18892782.jpg" alt="5"/>
? ? </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" class="arrow"><</a>
? ? <a href="javascript:;" id="next" class="arrow">></a>
</div>
</div>
</body>
</html>
2016-07-30
你還沒(méi)寫(xiě)完吧,這是我的所有代碼,你比對(duì)一下吧,希望能幫到你
2016-07-30