hover property in CSS doesn't work when I have an inline styles

前端 未结 2 1773
再見小時候
再見小時候 2021-01-26 06:07

I was work on a HTML document and I wanted to use the hover property for a HTML: div element but it didn\'t work. here the HTML div and the CSS style I used

<         


        
2条回答
  •  不思量自难忘°
    2021-01-26 06:41

    Inline styles can be overridden by !important, as they take up more importance.

    div:hover {background-color: red !important;}
    

    Something a bit about the specificity.

    Since you have the style attribute, it overrides all the other things! It is a sin to use !important:

提交回复
热议问题