How to create a frosted glass effect using CSS?

后端 未结 7 1153
独厮守ぢ
独厮守ぢ 2020-12-01 06:12

I\'d like to create a div that is fixed in one position and make it translucent - making the contents behind it partially visible and blurred. The style I\'m lo

7条回答
  •  隐瞒了意图╮
    2020-12-01 06:16

    CSS

    CSS 3 has a blur filter (only webkit at the moment Nov 2014):

    -webkit-filter: blur(3px); /*chrome (android), safari (ios), opera*/
    

    IE 4-9 supports a non-standard filter

    filter:progid:DXImageTransform.Microsoft.Blur(PixelRadius='3')
    

    See some nice demo for the blur and other filters here.

    webkit CSS filter blur example

    For future reference here is the compatibility table for CSS filter. Firefox seems to be getting the feature in v35+ while even IE11 does not seem to have any compatibility.

    SVG

    An alternative is using svg (safe for basically IE9 and up):

    filter: url(blur.svg#blur);
    

    SVG:

    
       
           
       
     
    

    jsFiddle Demo

    Javascript

    You will achieve the highest browser compatibility with javascript, but usually the slowest performance and added complexity to your js.

    • http://www.blurjs.com/ (jquery plugin, canvas solution so IE9+, FF, Chrome support)
    • http://nbartlomiej.github.io/foggy/ (jquery plugin IE8+, FF,Chrome support)

提交回复
热议问题