Change image on hover

前端 未结 9 649
鱼传尺愫
鱼传尺愫 2020-12-03 03:02

How can I change this exact code to do the hovering effect on mouseover?

I tried following some of the other questions and answers, but I could not really follow the

9条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-03 03:47

    If you don't want to do Javascript you can use CSS and :hover selector to get the same effect.

    Here's how:

    index.html:

    
    
    
    
    Image hover example
    
    
    

    stylesheet.css

    .change_img { background-image:url('img.png'); }/*Normal Image*/
    .change_img:hover { background-image:url('img_hover.png'); }/*On MouseOver*/
    

提交回复
热议问题