<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
*{
margin: 0;
padding: 0;
}
ul,ol{
list-style: none;
}
img{
vertical-align: top;
}
#box{
width: 300px;
height: 200px;
border: 1px solid #ccc;
padding: 5px;
margin: 100px auto;
}
.inner{
width: 100%;
height: 100%;
position: relative;
overflow: hidden;
}
.inner ul{
width: 1000%;
position: absolute;
left: 0;
}
.inner ul li{
float: left;
}
#arr{
display: none;
position: relative;
top: -50%;
}
#arr span{
width: 40px;
height: 40px;
position: absolute;
left: 5px;
top: 50%;
margin-top: -20px;
background-color: #ccc;
font-size: 40px;
text-align: center;
cursor: pointer;
}
#arr #right{
right: 5px;
left: auto;
}
</style>
</head>
<body>
<div id="box">
<div class="inner">
<ul>
<li><img src="images/1.jpg" alt=""/></li>
<li><img src="images/2.jpg" alt=""/></li>
<li><img src="images/3.jpg" alt=""/></li>
<li><img src="images/4.jpg" alt=""/></li>
<li><img src="images/1.jpg" alt=""/></li>
</ul>
</div>
<div id="arr">
<span id="left"><</span>
<span id="right">></span>
</div>
</div>
</body>
</html>
<script>
function $(id){return document.getElementById(id)}
var ul = $("box").children[0].children[0];
var arr = $("arr");
$("box").onmouseover = function () {
$("arr").style.display = "block";
}
$("box").onmouseout = function () {
$("arr").style.display = "none";
}
var start = 0,end =0;
$("left").onclick = function () {
end +=300;
}
$("right").onclick = function () {
end -=300;
}
setInterval(function () {
if(end>=0){
end=0;
}else if(end<=-1200){
end=-1200;
}
start = start + (end-start)/10;
ul.style.left = end+"px";
},30);
</script>
带左右箭头的焦点图
最新推荐文章于 2021-06-07 13:09:40 发布
622

被折叠的 条评论
为什么被折叠?



