カルーセルを作成しようとしていますが、要素を div リストの末尾から削除して先頭に適用した後、リストの先頭のスペースを占有することなく、他の要素を下に移動するだけです。この件で私を助けてくれるかどうか見てください。
コードは次のとおりです。ボタンを使用してカルーセルを開始します。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script src="jquery-1.3.2.js"></script>
<script>
$(function(){
$("#but").click(function(){
$(".slides").animate({left: "+=170"},2000);
//$('.wrap div').last().before$('.wrap div').first(;
timer=setInterval(function() {
//$(".wrap div:first-child").before($(".wrap div:last-child"))
$( ".wrap div:first-child" ).before($( ".wrap div:last-child" ));
},2000);
});
});
</script>
<style>
.wrap
{
border:1px solid red;
width:1000px;
overflow:hidden;
height:100px;
}
.slides
{
width:150px;
height:150px;
border:1px solid #C6F;
margin-left:2px;
margin-right:2px;
float:left;
margin-top:2px;
margin-bottom:2px;
text-align:center;
position:relative;
}
</style>
</head>
<body>
<div class="container">
<div class="wrap">
<div class="slides">1</div>
<div class="slides">2</div>
<div class="slides">3</div>
<div class="slides">4</div>
<div class="slides">5</div>
</div>
</div>
<button id ="but">hello</button>
</body>
</html>