我有一些来自旋转器的 css 动画,但我不能让它在谷歌浏览器中工作,我已经阅读了很多帖子,发现我缺少 WebKit 浏览器的关键帧规则,但我不知道如何制作它
这是我的 css 和 html
@keyframes spin {
to { transform: rotate(1turn); }
}
.progress-loading {
position: relative;
display: inline-block;
width: 5em;
height: 5em;
margin: 0 .5em;
font-size: 12px;
text-indent: 999em;
overflow: hidden;
animation: spin 1s infinite steps(8);
}
.small.progress-loading {
font-size: 6px;
}
.large.progress-loading {
font-size: 24px;
}
.progress-loading:before,
.progress-loading:after,
.progress-loading > div:before,
.progress-loading > div:after {
content: '';
position: absolute;
top: 0;
left: 2.25em; /* (container width - part width)/2 */
width: .5em;
height: 1.5em;
border-radius: .2em;
background: #eee;
box-shadow: 0 3.5em #eee; /* container height - part height */
transform-origin: 50% 2.5em; /* container height / 2 */
}
.progress-loading:before {
background: #555;
}
.progress-loading:after {
transform: rotate(-45deg);
background: #777;
}
.progress-loading > div:before {
transform: rotate(-90deg);
background: #999;
}
.progress-loading > div:after {
transform: rotate(-135deg);
background: #bbb;
}
HTML
<div class="small progress-loading"><div>Loading…</div></div>
和工作 fiddle ,请在 chrome 中检查它不起作用:( http://fiddle.jshell.net/ynoLjs1c/3/
最佳答案
您缺少 -webkit-
前缀。始终检查 browser support .
@keyframes spin {
to {
transform: rotate(1turn);
}
}
@-webkit-keyframes spin {
to {
-webkit-transform: rotate(1turn);
transform: rotate(1turn);
}
}
.progress-loading {
position: relative;
display: inline-block;
width: 5em;
height: 5em;
margin: 0 .5em;
font-size: 12px;
text-indent: 999em;
overflow: hidden;
-webkit-animation: spin 1s infinite steps(8);
animation: spin 1s infinite steps(8);
}
.small.progress-loading {
font-size: 6px;
}
.large.progress-loading {
font-size: 24px;
}
.progress-loading:before,
.progress-loading:after,
.progress-loading > div:before,
.progress-loading > div:after {
content: '';
position: absolute;
top: 0;
left: 2.25em;
/* (container width - part width)/2 */
width: .5em;
height: 1.5em;
border-radius: .2em;
background: #eee;
box-shadow: 0 3.5em #eee;
/* container height - part height */
transform-origin: 50% 2.5em;
/* container height / 2 */
}
.progress-loading:before {
background: #555;
}
.progress-loading:after {
transform: rotate(-45deg);
background: #777;
}
.progress-loading > div:before {
transform: rotate(-90deg);
background: #999;
}
.progress-loading > div:after {
transform: rotate(-135deg);
background: #bbb;
}
<div class="small progress-loading">
<div>Loading…</div>
</div>
关于html - Css 动画在 Google Chrome 中不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27423968/