横向自动轮播图

<script src="js/jquery-1.11.1.min.js"></script>
<title></title>
<style type="text/css">
*
{
padding: 0px;
margin: 0px;
}
.divOuter
{
width: 1620px;
height: 230px;
position: relative;
}
.divContianerImg
{
height: 230px;
width: 1085px;
border: 1px solid black;
overflow: hidden;
position: absolute;
left: 300px;
}

.divContianerImg img
{
width: 250px;
cursor:pointer;
}

.divContianerImg ul
{
list-style-type: none;
margin-top: 10px;
width: 1620px;
position: absolute;
left: -270px;
}

.divContianerImg li
{
float: left;
margin: 10px;
width: 250px;
}
.btnLeft
{
left:150px;
}
.btnRight
{
right:100px;
}
.btnRemove
{
position:absolute;
top:40%;
width:50px;
height:50px;
border-radius:100%;
border:1px solid gray;
text-align:center;
line-height:50px;
cursor:pointer;
font-size:2em;
font-weight:bolder;
}
.btnRemove:hover
{
background-color:#DADADA;
color:white;
}
</style>
</head>
<body>


<div class="divOuter">
<div οnclick="Left()" class="btnRemove btnLeft"><</div>
<div οnclick="Right()" class="btnRemove btnRight" >></div>
<div class="divContianerImg">

<ul>
<li title="1">
<img src="images/wall1.jpg" /></li>
<li title="2">
<img src="images/wall2.jpg" /></li>
<li title="3">
<img src="images/wall3.jpg" /></li>
<li title="4">
<img src="images/wall4.jpg" /></li>
<li title="5">
<img src="images/wall5.jpg" /></li>
<li title="6">
<img src="images/wall6.jpg" /></li>
<li title="7">
<img src="images/wall7.jpg" /></li>
</ul>
</div>
</div>
</body>
</html>
<script type="text/javascript">

var a = ["/images/wall1.jpg", "/images/wall2.jpg", "/images/wall3.jpg", "/images/wall4.jpg", "/images/wall5.jpg", "/images/wall6.jpg", "/images/wall7.jpg", "/images/wall8.jpg"];
function Right() {
$(".btnRight").removeAttr("onclick");
var i = parseInt($(".divContianerImg").find("ul li:last-child").attr("title"));
if (i + 1 == 9) {
i = 0;
}
i = i + 1;
$(".divContianerImg").find("ul").append("<li title='" +i + "'><img src='" + a[i-1] + "' /></li>");
$(".divContianerImg").find("ul").animate({ marginLeft: "-220px" }, 1000, function () {
$(".divContianerImg").find("ul").css("marginLeft", "0px");
$(".divContianerImg").find("ul li:first-child").remove();
$(".btnRight").attr("onclick", "Right()");
})
}
function Left() {
$(".btnLeft").removeAttr("onclick");
var i = parseInt($(".divContianerImg").find("ul li:first-child").attr("title"));
var check = $(".divContianerImg").find("ul li:first-child").find("img").attr("src");
i = i - 1;
if (i == 0) {
i = 8;
}
$(".divContianerImg").find("ul").animate({ marginLeft: "220px" }, 1000, function () {
$(".divContianerImg").find("ul").prepend("<li title='" + i + "'><img src='" + a[i - 1] + "' /></li>");
$(".divContianerImg").find("ul").css("marginLeft", "0px");
$(".divContianerImg").find("ul li:last-child").remove();
$(".btnLeft").attr("onclick", "Left()");
})
}
var RemoveLeft = setInterval("Right()", 5000)
$(".btnRemove").hover(function () {
clearInterval(RemoveLeft);
}, function () {
RemoveLeft = setInterval("Right()",5000);
});
$(".divContianerImg").find("img").hover(function () {
clearInterval(RemoveLeft);
}, function () {
RemoveLeft = setInterval("Right()", 5000);
});

</script>

转载于:https://www.cnblogs.com/-maomao/p/4723294.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值