明天要考试了,求这道题代码,HTML 100

 我来答
百度网友4e1dc15
2018-06-05
知道答主
回答量:23
采纳率:25%
帮助的人:1.9万
展开全部
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
body,ul,li,img{
margin: 0;
padding: 0;
}
div{
width: 992px;
height: 460px;
margin: 0 auto;
position: relative;
overflow: hidden;
}
ul{
list-style: none;
width: 3968px;
height: 460px;
position: absolute;
top: 0px;
left: 0px;
}
ul>li{
width: 992px;
height: 460px;
float: left;
}
.box{
width: 992px;
height: 200px;
margin: 0 auto;
}
ol{
list-style: none;
width: 992px;
height: 200px;
}
ol>li{
float: left;
width: 200px;
height: 92px;
margin-left: 20px;
}
span{
display: block;
width: 60px;
height: 460px;
background: #000000;
opacity: 0.4;
text-align: center;
line-height: 460px;
font-size: 16px;
color: #FFFFFF;
cursor: pointer;
}
#btnLeft{
position: absolute;
left: 0px;
top: 0px;
}
#btnRight{
position: absolute;
right: 0px;
top: 0px;
}
</style>
</head>
<body>
<div>
<ul>
<li><img src="img/0.jpg"/></li>
<li><img src="img/1.jpg"/></li>
<li><img src="img/2.jpg"/></li>
<li><img src="img/3.jpg"/></li>
</ul>
<span id="btnLeft">《</span>
<span id="btnRight">》</span>
</div>
<div class="box">
<ol>
<li><img src="img/0.jpg"/ width="200px" height="92px"></li>
<li><img src="img/1.jpg"/ width="200px" height="92px"></li>
<li><img src="img/2.jpg"/ width="200px" height="92px"></li>
<li><img src="img/3.jpg"/ width="200px" height="92px"></li>
</ol>
</div>

</body>
<script type="text/javascript">
var d = document.getElementsByTagName('div')[0]
var ulBox = document.getElementsByTagName('ul')[0]
var btnLeft = document.getElementById('btnLeft')
var btnRight = document.getElementById('btnRight')
var olBOx = document.getElementsByTagName('ol')[0]
var olLiArr = olBOx.getElementsByTagName('li')

var zd = null

for (var i = 0; i < olLiArr.length; i++) {
olLiArr[i].index = i
olLiArr[i].onclick = function(){
clearInterval(zd)
ulBox.style.left = -(this.index * 992) + 'px'
sj()
}
}
btnLeft.onclick=function(){
var leftLen = ulBox.offsetLeft
if(leftLen <= 0 ){
return
}
ulBox.style.left = (leftLen + 992) + 'px'
ulBox.style.transition = '0.4s'

}
btnRight.onclick=function(){
var leftLen = ulBox.offsetLeft
if(leftLen <= -2976){
return
}
ulBox.style.left = (leftLen - 992) + 'px'
ulBox.style.transition = '0.4s'
}
d.onmousemove=function(){
clearInterval(zd)
}
d.onmouseout=function(){
sj()
}
function sj(){
zd = setInterval(function(){
var leftLen = ulBox.offsetLeft
if(leftLen <= -2976){
ulBox.style.left = 0 + 'px'
return
}
ulBox.style.left = (leftLen - 992) + 'px'
ulBox.style.transition = '0.4s'
},2000)
}
sj()
</script>
</html>
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式