【发布时间】:2014-02-09 13:34:36
【问题描述】:
我正在使用 CSS3 动画创建选取框效果。
#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; }
}
<div id="caption">
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. the quick brown fox jumps over the lazy dog.
</div>
现在我可以得到基本的选框效果了,但是代码对于这个演示来说太具体了。
有没有办法避免使用像margin-left:-4200px; 这样的特定值,以便它可以适应任何长度的文本?
这是一个类似的演示:http://jsfiddle.net/jonathansampson/XxUXD/ 使用 text-indent,但仍具有特定值。
【问题讨论】:
标签: html css css-animations