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

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

箭頭切換問題。。

想實現(xiàn)按下箭頭圖片切換。代碼如下,實際卻未實現(xiàn)。請大神看看問題出在哪?

<div>有關(guān)圖片的定義:

<div id="container">

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

? ? ? ? <img src="img/5.jpg" alt="1"/>

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

</div>

在<div>中定義一對左右箭頭代碼如下:

? </div>

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

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

</div>

在CSS中設(shè)置樣式代碼如下:

.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;}

在<script>中定義當按下箭頭切換到下張圖片:

next.onclick=function(){

animate(-600);

}

prev.onclick=function(){

animate(600);

}

function animate(offset){

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

}

}



正在回答

1 回答

<!DOCTYPE?HTML>
<html>
<head>
????<meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8">
????<title>無標題文檔</title>
????<style>
????????.arrow?{
????????????cursor:?pointer;
????????????display:?inline-block;
????????????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;
????????}
????????#list{
????????????height:?400px;
????????????position:?absolute;
????????????top:0;
????????????left:?0;
????????}
????????#list?img{
????????????width:?600px;
????????????height:?400px;
????????????float:?left;
????????}
????????#container{
????????????width:?600px;
????????????height:?400px;
????????????position:?relative;
????????????overflow:?hidden;
????????????margin:?0?auto;
????????}
????</style>
</head>
<body>
????<div?id="container">
????????<div?id="list"?style="left:?0">
????????????<img?src="img/5.jpg"?alt="5"/>
????????????<img?src="img/1.jpg"?alt="1"/>
????????</div>
????????<a?href="javascript:;"?id="prev"?class="arrow">&lt;</a>
????????<a?href="javascript:;"?id="next"?class="arrow">&gt;</a>
????</div>
????<script?type="text/javascript">
????????var?next?=?document.getElementById('next');
????????var?list?=?document.getElementById('list');
????????var?imgs?=?list.getElementsByTagName('img');
????????next.onclick?=?function?()?{
????????????if(parseInt(list.style.left)<=?(-600?*?(imgs.length-1))){
????????????????return?;
????????????}
????????????animate(-600);
????????}
????????var?prev?=?document.getElementById('prev');
????????prev.onclick?=?function?()?{
????????????if(parseInt(list.style.left)>=?0){
????????????????return?;
????????????}
????????????animate(600);
????????}
????????function?animate(offset)?{
????????????list.style.left?=?parseInt(list.style.left)?+?offset?+?'px';
????????}
????</script>

</body>
</html>


也不知道你的完整代碼是什么樣的,就盡量按照你的來寫的

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

橙子lovesun 提問者

可以解釋一下這部分代碼嗎?沒懂什么意思。謝謝啦~ if(parseInt(list.style.left)<= (-600 * (imgs.length-1))){ return ; }
2015-12-06 回復(fù) 有任何疑惑可以回復(fù)我~
#2

李曉健 回復(fù) 橙子lovesun 提問者

就是如果到了最后一張,再點擊下一張就不去執(zhí)行了呀。下面的一個也是如果到了第一張,再點前一張就不去執(zhí)行。
2015-12-07 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消
焦點圖輪播特效
  • 參與學習       65327    人
  • 解答問題       634    個

通過本教程學習您將能掌握非常實用的焦點圖輪播特效的制作過程

進入課程

箭頭切換問題。。

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

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

幫助反饋 APP下載

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

公眾號

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