我尝试在div中的文本中进行无限和自动滚动(对于starwars通用方式)。 当前代码有效,但结果根本不流畅。
我不明白为什么,我希望这是流动的。
这是我的代码:
$(function(){
setInterval(function(){
$(".slideshow ul").animate({marginTop:-20}, 500, function(){
$(this).css({marginTop:0}).find("li:last").after($(this).find("li:first"));
})
}, 500);
});
$(document).ready(function(){
$(function(){
setInterval(function(){
$(".slideshow ul").animate({marginTop:-20}, 500, function(){
$(this).css({marginTop:0}).find("li:last").after($(this).find("li:first"));
})
}, 500);
});
});
body {
background: url(img/1.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.head {
width: 100%;
height: 150px;
text-align: center;
background-color: rgba(255,255,255, 0.2);
}
.users {
margin-top: 20px;
padding-top: 20px;
height: 400px;
text-align: center;
background-color: rgba(255,255,255, 0.2);
}
#suscrib {
height: 45px;
font-size: 15px !important;
}
.slideshow {
width: 200px;
height: 370px;
overflow: hidden;
/*border: 3px solid #F2F2F2;*/
}
.slideshow ul {
/* 4 images donc 4 x 100% */
width: 100%;
height: 200px;
padding:0; margin:0;
list-style: none;
}
.slideshow li {
color: red;
font-family: 'Satisfy';
font-size: 15px;
}
.thanks {
margin-top: 20px;
text-align: center;
font-family: 'Dancing Script';
font-size: 40px;
color: red;
}
#ombre {
box-shadow: 3px 3px 43px #000 !important;
}
h1 {
padding-top: 80px;
opacity: 1 !important;
z-index: 10;
}
#logo {
height: 150px;
width: 150px;
margin-top: 0px;
}
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
</head>
<body>
<div class="row">
<div class="users col-lg-2 col-lg-offset-5" id="ombre">
<div class="slideshow col-lg-12 ">
<ul id="pushme">
<li> <div id='suscrib'> User user </div> </li>
<li> <div id='suscrib'> User user2 </div> </li>
<li> <div id='suscrib'> User user3 </div> </li>
<li> <div id='suscrib'> User user4 </div> </li>
<li> <div id='suscrib'> User user </div> </li>
<li> <div id='suscrib'> User user </div> </li>
<li> <div id='suscrib'> User user </div> </li>
<li> <div id='suscrib'> User user </div> </li>
<li> <div id='suscrib'> User user </div> </li>
<li> <div id='suscrib'> User user10 </div> </li>
<li> <div id='suscrib'> User user </div> </li>
<li> <div id='suscrib'> User user </div> </li>
</ul>
</div>
</div>
</div>
</div>
</body>
</html>
编辑:检查新代码段 非常感谢!
答案 0 :(得分:1)
所以,这里有些不对劲。
$(document).ready(function(){
$(function(){
setInterval(function(){
$(".slideshow ul").animate({marginTop:-45}, 2000, "linear", function(){
$(this).css({marginTop:0}).find("li:last").after($(this).find("li:first"));
})
}, 2000);
});
});
body {
background: url(img/1.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.head {
width: 100%;
height: 150px;
text-align: center;
background-color: rgba(255,255,255, 0.2);
}
.users {
margin-top: 20px;
padding-top: 20px;
height: 400px;
text-align: center;
background-color: rgba(255,255,255, 0.2);
}
.suscrib {
height: 45px;
font-size: 15px !important;
}
.slideshow {
width: 200px;
height: 370px;
overflow: hidden;
/*border: 3px solid #F2F2F2;*/
}
.slideshow ul {
/* 4 images donc 4 x 100% */
width: 100%;
height: 200px;
padding:0; margin:0;
list-style: none;
}
.slideshow li {
color: red;
font-family: 'Satisfy';
font-size: 15px;
}
.thanks {
margin-top: 20px;
text-align: center;
font-family: 'Dancing Script';
font-size: 40px;
color: red;
}
#ombre {
box-shadow: 3px 3px 43px #000 !important;
}
h1 {
padding-top: 80px;
opacity: 1 !important;
z-index: 10;
}
#logo {
height: 150px;
width: 150px;
margin-top: 0px;
}
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
</head>
<body>
<div class="row">
<div class="users col-lg-2 col-lg-offset-5" id="ombre">
<div class="slideshow col-lg-12 ">
<ul id="pushme">
<li> <div class='suscrib'> User user </div> </li>
<li> <div class='suscrib'> User user2 </div> </li>
<li> <div class='suscrib'> User user3 </div> </li>
<li> <div class='suscrib'> User user4 </div> </li>
<li> <div class='suscrib'> User user </div> </li>
<li> <div class='suscrib'> User user </div> </li>
<li> <div class='suscrib'> User user </div> </li>
<li> <div class='suscrib'> User user </div> </li>
<li> <div class='suscrib'> User user </div> </li>
<li> <div class='suscrib'> User user10 </div> </li>
<li> <div class='suscrib'> User user </div> </li>
<li> <div class='suscrib'> User user </div> </li>
</ul>
</div>
</div>
</div>
</div>
</body>
</html>