【发布时间】:2016-02-15 14:13:14
【问题描述】:
我创建了一个锚链接按钮,当我单击处于:focus 状态的按钮时,我想在其中显示 Spinner 动画。我正在使用 Font Awesome 来显示动画,但是当我单击按钮时,微调器动画不起作用。
注意:我这里不想用 JavaScript 只想用 Pure CSS
这里是 CodePen 链接https://codepen.io/rhulkashyap/pen/vLPNdQ
@import url(https://fonts.googleapis.com/css?family=Titillium+Web);
body {
font-family: 'Titillium Web', sans-serif;
text-align: center;
}
#button {
padding: 15px;
background-color: green;
color: #fff;
text-decoration: none;
border-radius: 5px;
width: 300px;
display: inline-block;
text-align: center;
font-size: 25px;
-webkit-transition: all .3s ease-in-out;
transition: all .3s ease-in-out;
}
#button:before {
content: "\f090";
font-family: FontAwesome;
margin-right: 5px;
}
#button:focus {
background-color: #02b402;
}
#button:focus:before {
content: "\f1ce";
-webkit-animation: spin .8s ease infinite;
animation: spin .8s ease infinite;
}
@-webkit-keyframes spin {
from {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
to {
-webkit-transform: rotate(359deg);
transform: rotate(359deg);
}
}
@keyframes spin {
from {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
to {
-webkit-transform: rotate(359deg);
transform: rotate(359deg);
}
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet" />
<h2> Click Here</h2>
<a id="button" href="javascript:void(0)">Enter In</a>
【问题讨论】:
-
它似乎工作正常(Chrome)。您使用的是什么浏览器,不工作是什么意思?
-
我使用的是 Firefox 开发者版
标签: html css css-animations css-transforms