我试图通过CSS3宽度过渡来实现页面加载的加载效果。
这里是demo http://jsfiddle.net/Ajey/LX3W5/.
HTML
<div class="skill-bar">
<span class="w70"></span>
</div>
CSS
.skill-bar {
width: 57%;
float: left;
height: 11px;
border-radius: 5px;
position: relative;
margin: 6px 0 12px 0;
border: 2px solid #00edc2;
}
.skill-bar span {
background: #00edc2;
height: 7px;
border-radius: 5px;
display: inline-block;
}
.skill-bar span.w70 {
width: 70%;
}
.skill-bar span {
width: 0;
transition: width 1s ease;
-webkit-transition: width 1s ease;
background-color: #00edc2;
}
它没有按预期工作。我需要在页面加载时进行转换。
但是当我检查元素并选中/取消选中width
的跨度,我得到了效果。
如何对页面加载产生相同的效果?
您可以使用 CSS 动画实现无需 JavaScript 且没有任何兼容性问题的效果:
<div class="skill-bar">
<span class="w70"></span>
</div>
.skill-bar {
width: 57%;
float: left;
height: 11px;
border-radius: 5px;
position: relative;
margin: 6px 0 12px 0;
border: 2px solid #00edc2;
}
.skill-bar span {
background: #00edc2;
height: 7px;
border-radius: 5px;
display: inline-block;
}
.skill-bar span {
animation: w70 1s ease forwards;
}
.skill-bar .w70 {
width: 70%;
}
@keyframes w70 {
from { width: 0%; }
to { width: 70%; }
}
webkit 的小提琴:http://jsfiddle.net/ySj7t/ http://jsfiddle.net/ySj7t/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)