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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

這段js代碼為什么會(huì)一直抖動(dòng)

這段js代碼為什么會(huì)一直抖動(dòng)

madnesslin 2016-08-20 12:18:31
window.onload?=?function(){ ????var?returnHome?=?document.getElementById('return-home'); ????var?returnLeft?=?document.getElementById('return-home-left'); ????var?returnRight?=?document.getElementById('return-home-right'); ????returnRight.onclick?=?function(){ ????????startMove(0,10); ????}; ????returnLeft.onclick?=?function(){ ????????startMove(-250,-10); ????}; ????var?timer?=?null; ????function?startMove(a,b){ ????????var?returnHome?=?document.getElementById('return-home'); ????????setInterval(function(){ ????????????if(returnHome.offsetLeft?===?a){ ????????????????clearInterval(null); ????????????}else{ ????????????????returnHome.style.left?=?returnHome.offsetLeft?+?b?+"px"; ????????????} ????????},30); ????} };<!DOCTYPE?html> <html> ????<head> ????????<meta?charset="utf-8"> ????????<meta?http-equiv="X-UA-Compatible"?content="IE=edge"> ????????<meta?name="viewport"?content="width=device-width,?initial-scale=1"> ????????<title>返回首頁</title> ????????<link?href="./return-home.css"?rel="stylesheet">?<!--?/css樣式表?--> ????????<link?href="./icomoon-common/style.css"?rel="stylesheet">?<!--?/圖標(biāo)字體?--> ????</head> ????<body> ????????<!--?整個(gè)ul丟進(jìn)去?--> ????????<ul?id="return-home"> ????????????<li?class="left?sidebar"?id="return-home-left"> ????????????????<a?href="javascript:;"> ????????????????????<span></span>?關(guān) ????????????????</a> ????????????</li> ????????????<li> ????????????????<a?href="#"> ????????????????????<span></span>?首頁 ????????????????</a> ????????????</li> ????????????<li> ????????????????<a?href="#"> ????????????????????<span></span>?首頁 ????????????????</a> ????????????</li> ????????????<li> ????????????????<a?href="#"> ????????????????????<span?class="?icon-play"></span>?首頁 ????????????????</a>'' ????????????</li> ????????????<li> ????????????????<a?href="#"> ????????????????????<span></span>?首頁 ????????????????</a> ????????????</li> ????????????<li?class="right?sidebar"?id="return-home-right"> ????????????????<a?href="javascript:;"> ????????????????????<span></span>?開 ????????????????</a> ????????????</li> ????????</ul> ????????<script?src="./return-home.js"></script>?<!--?/整段js代碼??--> ????</body> </html>@charset?'UTF-8'; .return-home { ????font-size:?0; ????position:?fixed; ????z-index:?999999; ????bottom:?5%; ????/*left:?calc(100%?/?6?-?100%);*/ ????left:?-250px; ????display:?inline-block; ????overflow:?hidden; ????width:?300px; ????height:?50px; ????margin:?0; ????padding:?0; ????opacity:?.7; ????border:?0; ????background-color:?white; } .return-home?li { ????font-size:?0; ????display:?inline-block; ????width:?50px; ????height:?100%; ????margin:?0; ????padding:?0; ????list-style:?none; ????border:?0; } .return-home?.sidebar { ????background-color:?transparent; } .return-home?.sidebar?a { ????color:?#666; } .return-home?li?a { ????font-size:?14px; ????display:?inline-block; ????width:?100%; ????height:?100%; ????text-align:?center; } .return-home?li?a?span { ????font-size:?24px; ????display:?inline-block; ????width:?100%; ????margin-top:?5px; }
查看完整描述

2 回答

?
stone310

TA貢獻(xiàn)361條經(jīng)驗(yàn) 獲得超191個(gè)贊

有幾個(gè)地方要注意和修改的:

1、startMove(0,10),表達(dá)的意思是以10px的速度到達(dá)left為0的位置

如果你body初始margin(好像是8)沒有去掉(我看你CSS代碼上面沒有),那么你用offsetLeft初始位置就是8,你以每次10px的速度永遠(yuǎn)到不了offsetLeft=0這個(gè)位置

2、if(returnHome.offsetLeft?===?a){

????????????????clearInterval(null);

????????????}

這個(gè)動(dòng)畫停不了,給setInterval起個(gè)名字,然后再把null換掉

3、function?startMove(a,b)函數(shù)一開始要放置一個(gè)clearInterval,否則多次點(diǎn)擊計(jì)時(shí)器會(huì)疊加(點(diǎn)一下左點(diǎn)一下右就在那亂抖)

查看完整回答
2 反對(duì) 回復(fù) 2016-08-20
?
qq_晝綻_0

TA貢獻(xiàn)82條經(jīng)驗(yàn) 獲得超17個(gè)贊

圖標(biāo)字體的沒給,

查看完整回答
反對(duì) 回復(fù) 2016-08-20
  • 2 回答
  • 0 關(guān)注
  • 1680 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

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