如何在webkit浏览器之前为伪元素设置动画?

时间:2012-11-03 05:47:07

标签: css css3 webkit css-transitions

  

可能重复:
  CSS3 transitions on pseudo-elements (:after, :before) not working?

我的CSS转换仅适用于Firefox ...不确定为什么它不能在chrome,safari或Opera中动画。

这是一个小提琴:http://jsfiddle.net/chovy/HUDuy/

HTML:

<ol class="steps">
        <li>Foo</li>
        <li>Bar</li>
        <li>Baz</li>
</ol>

CSS:

ol.steps {
  list-style-type: none;
  counter-reset: step-counter;
  padding-left: 60px;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

ol.steps li {
  position: relative;
  padding: 10px 20px;
  height: 50px;
}

ol.steps li:before {
  content: counter(step-counter, decimal);
  counter-increment: step-counter;
  position: absolute;
  left: -50px;
  top: 10px;
  border: 1px solid #ccc;
  width: 45px;
  height: 45px;
  line-height: 45px;
  border-radius: 50px;
  background: #f9f9f9;
  text-align: center;
  font-size: 28px;
  color: #aaa;
  -webkit-transition: all 0.25s ease-in-out;
  -moz-transition: all 0.25s ease-in-out;
  -o-transition: all 0.25s ease-in-out;
  -ms-transition: all 0.25s ease-in-out;
  transition: all 0.25s ease-in-out;
}

ol.steps li:hover:before {
  width: 60px;
  height: 60px;
  line-height: 60px;
  left: -57px;
  top: 2px;
  -webkit-transition: all 0.5s ease-in-out;
  -moz-transition: all 0.5s ease-in-out;
  -o-transition: all 0.5s ease-in-out;
  -ms-transition: all 0.5s ease-in-out;
  transition: all 0.5s ease-in-out;
}

1 个答案:

答案 0 :(得分:0)

如上所述here

WebKit(Chrome,Safari)不支持伪元素的转换。

Firefox的确如此。