CSS Transitions with :before and :after pseudo elements

纵饮孤独 提交于 2019-11-27 17:10:16

问题


Can't seem to animate pseudo elements with -webkit-transition. The fiddle below shows what I mean when run in Chrome/Safari, I guess this isn't supported right now?

http://jsfiddle.net/4rnsx/130/


回答1:


Fixed in Google Chrome on January 3rd, 2013.

By now (I do update this list) it's supported in:

  • FireFox 4.0 and above
  • Chrome 26 and above
  • IE 10 and above

Waiting for Safari and Chrome for Android to pull these updates.

You can test it yourself in your browser, or

See the browser support table.




回答2:


Well, actually, you can.

You just need to leverage the often forgotten inherit value. Unfortunately we can't (yet) directly target pseudo-elements with custom animations, but we surely can let them share the same animation of the "parent" element by inheriting the properties we wish to animate.

See my fiddle here.




回答3:


Nope, not supported yet



来源:https://stackoverflow.com/questions/9798010/css-transitions-with-before-and-after-pseudo-elements

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!