css: avoid image hover first time blinking

前端 未结 12 621
深忆病人
深忆病人 2020-12-07 19:52

I have an anchor that changes its background image when hovered with a class class-btn that contains a background-image.

When hovered, it

12条回答
  •  情书的邮戳
    2020-12-07 20:44

    If you do this:

    #the-button {
    background-image: url('images/img.gif');
    }
    #the-button:before {
      content: url('images/animated-img.gif');
      width:0;
      height:0;
      visibility:hidden;
    }
    
    #the-button:hover {
      background-image: url('images/animated-img.gif');
    }
    

    This will really help!

    See here:

    http://particle-in-a-box.com/blog-post/pre-load-hover-images-css-only

    P.S - not my work but a solution I found :)

提交回复
热议问题