Greyscale Background Css Images

后端 未结 5 2153
独厮守ぢ
独厮守ぢ 2020-11-27 14:42

I\'ve searched a lot on the web but I cannot find a cross browser solution to fade a css backgrund image to greyscale and back.

The only working solution is to apply

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 15:34

    Using current browsers you can use it like this:

    img {
      -webkit-filter: grayscale(100%); /* Chrome, Safari, Opera */
      filter: grayscale(100%);
    }
    

    and to remedy it:

    img:hover{
       -webkit-filter: grayscale(0%); /* Chrome, Safari, Opera */
       filter: grayscale(0%);
    }
    

    worked with me and is much shorter. There is even more one can do within the CSS:

    filter: none | blur() | brightness() | contrast() | drop-shadow() | grayscale() |
            hue-rotate() | invert() | opacity() | saturate() | sepia() | url();
    

    For more information and supporting browsers see this: http://www.w3schools.com/cssref/css3_pr_filter.asp

提交回复
热议问题