简体   繁体   English

旋转器为什么不旋转/旋转?

[英]Why is the spinner not spinning/rotating?

I have created a anchor link button where I want to show Spinner animation when I click on button in :focus state. 我创建了一个锚链接按钮,当我在:focus状态下单击按钮时,我想在其中显示Spinner动画 I'm using Font Awesome to show animation but when I click on the button, the spinner animation is not working. 我正在使用Font Awesome来显示动画,但是当我单击按钮时,微调器动画不起作用。

在此处输入图片说明

Note: I don't want to use JavaScript here just want to do with Pure CSS 注意:我不想在这里使用JavaScript,而只是想使用Pure CSS

Here is the CodePen link https://codepen.io/rhulkashyap/pen/vLPNdQ 这是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> 

Transforms are supposed to work only on block level elements (including inline-block ). 变换应该仅在块级元素(包括inline-block )上起作用。 Making the pseudo-element as display:inline-block makes the animation work. 将伪元素设为display:inline-block使动画起作用。

After commenting on the question, I did see that the animation wasn't working in Chrome v50 (dev-m) also while it was working in Chrome v43. 在对问题进行评论后,我确实看到动画在Chrome v43中也无法在Chrome v50(dev-m)中运行。 So, the current behavior seems to be consistent 因此,目前的行为似乎是一致的

 @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 { display: inline-block; 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> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM