问题
Is it possible to animate CSS's selectors :before and :after in jQuery's .animate() function? If not, what is the best alternative to doing that?
回答1:
In short no - jQuery does not support pseudo element animations or even selectors I believe.
You can however animate pseudo elements using css3 transitions but it is to note that only Firefox 4.0+ supports it currently, so your playing field is very limited.
If it's that important, just create new child elements in the element you want to animate them.
Update
Pseudo element animations/transitions are now supported in Chrome as of January 1st, 2013.
You can find a browser support table here.
来源:https://stackoverflow.com/questions/14109964/animating-csss-after-and-before-selectors-in-jquery