Is it possible to create inline pseudo styles?

前端 未结 5 1912
日久生厌
日久生厌 2020-12-03 10:33

Is it possible to create inline pseudo styles?

For instance, can I do something like the following?



        
5条回答
  •  既然无缘
    2020-12-03 11:17

    Unfortunately no, you can't implement hover effects using inline CSS.

    A (poor) work-around for this problem is to have your controls render style blocks when they are rendered. For example, your control could render as:

    
    Coding Horror
    

    If you could force your users to drop a "style control" at the top of their pages you could render all your custom classes there instead of rendering them next to each control, which would be a very, very bad thing (browsers will restart rendering every time they come across a style block, having a lot of style blocks scattered around your page will cause slow rendering).

    Unfortunately there's no elegant solution to this problem.

提交回复
热议问题