Blurring an image via CSS?

后端 未结 6 772
不知归路
不知归路 2020-12-08 13:13

On many smartphones (Samsung Galaxy II being an example) when you browse through a photo gallery, its blurred copy is laid out in the background. Can this be achieved by CSS

6条回答
  •  心在旅途
    2020-12-08 13:32

    With CSS3 we can easily adjust an image. But remember this does not change the image. It only displays the adjusted image.

    See the following code for more details.

    To make an image gray:

    img {
     -webkit-filter: grayscale(100%);
    }
    

    To give a sepia look:

    img {
     -webkit-filter: sepia(100%);
    }
    

    To adjust brightness:

    img {
     -webkit-filter: brightness(50%);
    }
    

    To adjust contrast:

    img {
     -webkit-filter: contrast(200%);
    }
    

    To Blur an image:

    img {
     -webkit-filter: blur(10px);
    }
    

    You should also do it for different browser. That is include all css statements

      filter: grayscale(100%);
     -webkit-filter: grayscale(100%);
     -moz-filter: grayscale(100%);
    

    To use multiple

     filter: blur(5px) grayscale(1);
    

    Codepen Demo

提交回复
热议问题