CSS3 Fade Effect

后端 未结 3 613
一整个雨季
一整个雨季 2020-11-28 08:54
a {
    float: left;
    width: 32px;
    height: 32px;
    text-align: left;
    text-indent:-9999px;
    background: url(\'../img/button.png\') no-repeat 0 0;

            


        
3条回答
  •  广开言路
    2020-11-28 09:42

    You can't transition between two background images, as there's no way for the browser to know what you want to interpolate. As you've discovered, you can transition the background position. If you want the image to fade in on mouse over, I think the best way to do it with CSS transitions is to put the image on a containing element and then animate the background colour to transparent on the link itself:

    span {
        background: url(button.png) no-repeat 0 0;
    }
    a {
        width: 32px;
        height: 32px;
        text-align: left;
        background: rgb(255,255,255);
    
        -webkit-transition: background 300ms ease-in 200ms; /* property duration timing-function delay */
        -moz-transition: background 300ms ease-in 200ms;
        -o-transition: background 300ms ease-in 200ms;
        transition: background 300ms ease-in 200ms;
        }
    a:hover {
        background: rgba(255,255,255,0);
    }
    

提交回复
热议问题