这是我的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>
并且工作小提琴,请在铬中chek它不起作用:( http://fiddle.jshell.net/ynoLjs1c/3/
答案 0 :(得分:1)
您缺少-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;
}
&#13;
<div class="small progress-loading">
<div>Loading…</div>
</div>
&#13;