【发布时间】:2016-06-02 11:38:14
【问题描述】:
我正在使用 css3 制作从宽度:0 到宽度:100% 的动画线。目前是从左到右移动,但我想让它从右到左开始。这对关键帧是否可行?
这是我的代码
.content {
width: 400px;
height: 200px;
color: white;
cursor: pointer;
text-transform: uppercase;
padding-bottom: 20px;
position: relative;
background: #333;
}
.content .line {
height: 2px;
background: white;
position: absolute;
top: 10px;
-webkit-animation: dude .75s 1 forwards;
-moz-animation: dude .75s 1 forwards;
-o-animation: dude .75s 1 forwards;
animation: dude .75s 1 forwards;
}
@-webkit-keyframes dude {
0% {
width: 0;
}
100% {
width: 100%;
}
}
@-moz-keyframes dude {
0% {
width: 0;
}
100% {
width: 100%;
}
}
@-o-keyframes dude {
0% {
width: 0;
}
100% {
width: 100%;
}
}
@keyframes dude {
0% {
width: 0;
}
100% {
width: 100%;
}
}
<div class="content">
<div class="line"></div>
</div>
【问题讨论】:
-
请记住,您甚至是 need to consider for CSS animations is
-webkit-... 的唯一前缀...我什至不会再为此烦恼了 :)-moz-和所有其他前缀都在这里膨胀。跨度>