Can I fade in a background image (CSS: background-image) with jQuery?

后端 未结 9 1166
一生所求
一生所求 2020-11-29 00:52

I have a div element with text in it and a background image, which is set via the CSS property background-image. Is it possible to fade in the back

9条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-29 01:02

    You can fade your background-image in various ways since Firefox 4 ...

    Your CSS:

    .box {
        background: #CCCCCC;
        -webkit-transition: background 0.5s linear;
        -moz-transition: background 0.5s linear;
        -o-transition: background 0.5s linear;
        transition: background 0.5s linear;
        }
    .box:hover {
        background: url(path/to/file.png) no-repeat #CCCCCC;
        }
    

    Your XHTML:

    Some Text …

    And thats it.

提交回复
热议问题