Inline style to act as :hover in CSS

前端 未结 7 2250
梦毁少年i
梦毁少年i 2020-12-01 02:11

I know that embedding CSS styles directly into the HTML tags they affect defeats much of the purpose of CSS, but sometimes it\'s useful for debugging purposes, as in:

<
7条回答
  •  我在风中等你
    2020-12-01 02:59

    I'm afraid it can't be done, the pseudo-class selectors can't be set in-line, you'll have to do it on the page or on a stylesheet.

    I should mention that technically you should be able to do it according to the CSS spec, but most browsers don't support it

    Edit: I just did a quick test with this:

    Test
    

    And it doesn't work in IE7, IE8 beta 2, Firefox or Chrome. Can anyone else test in any other browsers?

提交回复
热议问题