箭頭切換問題。。
想實現(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"><</a>
? ? <a href="javascript:;" id="next" class="arrow">></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';
}
}
2015-12-06
也不知道你的完整代碼是什么樣的,就盡量按照你的來寫的