第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

請問下面的代碼為什么無法實現(xiàn)自動播放?

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>焦點圖輪播特效</title>

<style type="text/css">

#container{

width: 680px;

height: 680px;

overflow: hidden;

position: relative;

}


? ? ? ? #list{

? ? ? ? ?width: 4760px;

? ? ? ? ?height: 680px;

? ? ? ? ?position: absolute;

? ? ? ? ?z-index: 1;

? ? ? ? }


? ? ? ? #list img { float: left;}


? ? ? ? #buttons{

? ? ? ? ?position: absolute;

? ? ? ? ?left: 300px;

? ? ? ? ?bottom: 20px;

? ? ? ? ?width: 100px;

? ? ? ? ?height: 10px;

? ? ? ? ? ? z-index: 2;

? ? ? ? }


? ? ? ? #buttons span{

? ? ? ? ?cursor: pointer;

? ? ? ? ?width: 10px;

? ? ? ? ?height: 10px;

? ? ? ? ?background-color: #333;

? ? ? ? ?border: solid #fff 1px;

? ? ? ? ?border-radius: 50%;

? ? ? ? ?margin-right: 5px;

? ? ? ? ?float: left;

? ? ? ? }


? ? ? ? #buttons .on{

? ? ? ? ?background-color: 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: 320px;

? ? ? ? ?background: rgba(0,0,0,0.3);

? ? ? ? ?color: #fff;

? ? ? ? ?text-decoration: none;

? ? ? ? }


? ? ? ? .arrow:hover{

? ? ? ? ?background-color: rgba(0,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 prev=document.getElementById('prev');

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

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

var index=1;

var animated=false;

var timer;

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){

animated=true;

var newLeft=parseInt(list.style.left) + offset;

var time=340;

var interval=10;//位移間隔時間

var speed=offset/(time/interval);


? ? ? ?var go = function (){

? ? ? ? ? ? ? ? ? ? if ( (speed > 0 && parseInt(list.style.left) < newLeft) || (speed < 0 && parseInt(list.style.left) > newLeft)) {

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

? ? ? ? ? ? ? ? ? ? ? ? setTimeout(go, interval);

? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? ? ? else{

? ? ? ? ? ? ? ? ? ? ?animated = false;

? ? ? ? ? ? ? ? ? ? ?list.style.left=newLeft+'px';

? ? ? ?if (newLeft>-680) {

? ? ? ? ? ? ? ? ? ?list.style.left =-3400 + 'px';

? ? ? ?}

? ? ? ?if (newLeft<-3400) {

? ? ? ? list.style.left =-680 + 'px';

? ? ? ? ? ? ? ?}

? ? ? ? ? ?}

? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? go();

}


? ? ? ? ? ? function play(){

? ? ? ? ? ? ?timer = setInterval(function(){

? ? ? ? ? ? ?next.onclick();

? ? ? ? ? ? ?},2000);

? ? ? ? ? ? }


? ? ? ? ? ? function stop(){

? ? ? ? ? ? ?clearInterval(timer);

? ? ? ? ? ? }


? ?prev.onclick=function(){

? ? if (index==1) {

? ? index=5;

? ? }

? ? else{

? ? index-=1;

? ? }

? ? showButton();

? ? if (!animated) {

? ? animate(680);

? ? }

? ?}


? ?next.onclick=function(){

? ? if (index==5) {

? ? index=1;

? ? }

? ? else{

? ? index+=1;

? ? }

? ? showButton();

? ?if (!animated) {

? ? animate(-680);

? ? }

? ?}


? ?for(var i =0 ;i<=buttons.length;i++){

? ? if (this.className=="on") {

? ? return;

? ? }

? ? buttons[i].onclick=function(){

? ? var myindex=parseInt(this.getAttribute('index'));

? ? var offset=-680*(myindex-index);

? ? ??if (!animated) {

? ? ?? animate(offset);

? ? ??}

? ? index=myindex;

? ? ? ? ? ? ? ? ? ? showButton();

? ? }

? ?}


? ?container.onmouseover = stop;

? ? ? ? ? ? container.onmouseout = play;


? ? ? ? ? ? play();

}

</script>

</head>

<body>

<div id="container">

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

>

<img src="img/235158io8t6qpuv8ev7tto.jpg" alt="1">

<img src="img/235158io8t6qpuv8ev7tto.jpg" alt="1">

<img src="img/235331hadx3yniynfxyl1d.jpg" alt="2">

<img src="img/235423iaeyknz18tdj66zc.jpg" alt="3">

<img src="img/235518ittnnkr0xuruttnx.jpg" alt="4">

<img src="img/235543ewinowim8nqtln7o.jpg" alt="5">

<img src="img/235543ewinowim8nqtln7o.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">&lt;</a>

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

</div>

</body>

</html>


正在回答

1 回答

我不是很清楚應該是代碼有錯誤

你可以看看firebug應該就知道哪里錯了


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

舉報

0/150
提交
取消

請問下面的代碼為什么無法實現(xiàn)自動播放?

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號