MouseOver and MouseOut In CSS

前端 未结 4 1434
有刺的猬
有刺的猬 2020-12-23 17:40

For using mouse into one element we use the :hover CSS attribute. How about for mouse out of the element?

I added a transition effect on the element to

4条回答
  •  礼貌的吻别
    2020-12-23 18:30

    You only need the :hover , when you mouse out of the element, it'll return to it's default non-:hover state, like this:

    .class { color: black; } 
    .class:hover { color: red; }
    

    when you hover, the color will be red and when you "mouseout", the color will return to black because it no longer matches the :hover selector. This is the default behavior for all browsers, nothing special you need to do here.

提交回复
热议问题