Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
CSS伪元素的动画不工作_Css - Fatal编程技术网

CSS伪元素的动画不工作

CSS伪元素的动画不工作,css,Css,我尝试旋转一个伪元素,然而,当动画在其他元素上完美工作时,伪元素不会移动 HTML: jsfiddle: 将动画规则应用于div有效,而::before无效。我缺少什么?将显示:内联块添加到您的:before @关键帧旋转{ 0% { 变换:旋转(0度); } 100% { 变换:旋转(359度); } } .旋转::之前{ 内容:“x”; 动画:旋转2s无限线性; 显示:内联块; } 太好了,谢谢你快速的回答(我还不能接受,但我会的)。你能解释一下原因吗?我想非块元素无法转换?@Tim Er

我尝试旋转一个伪元素,然而,当动画在其他元素上完美工作时,伪元素不会移动

HTML:

jsfiddle:


将动画规则应用于
div
有效,而
::before
无效。我缺少什么?

显示:内联块添加到您的:before

@关键帧旋转{
0% {
变换:旋转(0度);
}
100% {
变换:旋转(359度);
}
}
.旋转::之前{
内容:“x”;
动画:旋转2s无限线性;
显示:内联块;
}

太好了,谢谢你快速的回答(我还不能接受,但我会的)。你能解释一下原因吗?我想非块元素无法转换?@Tim Erwin是的。
<div class="spinning">
    some content
</div>
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(359deg);
  }
}

.spinning::before {
  content: 'x';
  animation: spin 2s infinite linear;
}