我正在用CSS3动画创建一个选框效果.这是我的代码.
HTML标签:
#caption {
position: fixed;
bottom: 0;
left: 0;
font-size: 20px;
line-height: 30px;
height:30px;
width: 100%;
white-space: nowrap;
-moz-animation: caption 50s linear 0s infinite;
-webkit-animation: caption 50s linear 0s infinite;
}
@-moz-keyframes caption {
0% { margin-left:120%; } 100% { margin-left:-4200px; }
}
@-webkit-keyframes caption {
0% { margin-left:120%; } 100% { margin-left:-4200px; }
}Run Code Online (Sandbox Code Playgroud)
CSS:
<div id="caption">
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. the quick brown …Run Code Online (Sandbox Code Playgroud) 我对Javascript毫无希望.这就是我所拥有的:
<script type="text/javascript">
function beginrefresh(){
//set the id of the target object
var marquee = document.getElementById("marquee_text");
if(marquee.scrollLeft >= marquee.scrollWidth - parseInt(marquee.style.width)) {
marquee.scrollLeft = 0;
}
marquee.scrollLeft += 1;
// set the delay (ms), bigger delay, slower movement
setTimeout("beginrefresh()", 10);
}
</script>
Run Code Online (Sandbox Code Playgroud)
它滚动到左边但我需要它相对无缝地重复.目前它只是跳回到开头.这可能不是我做的方式,如果没有,任何人都有更好的方法?