Background blur with CSS

前端 未结 7 2232
忘了有多久
忘了有多久 2020-11-27 13:34

I want an Vista/7-aero-glass-style effect on a popup on my site, and it needs to be dynamic. I\'m fine with this not being a cross-browser effect as long as

7条回答
  •  余生分开走
    2020-11-27 13:56

    There is a simple and very common technique by using 2 background images: a crisp and a blurry one. You set the crisp image as a background for the body and the blurry one as a background image for your container. The blurry image must be set to fixed positioning and the alignment is 100% perfect. I used it before and it works.

    body {
        background: url(yourCrispImage.jpg) no-repeat;
    }
    
    #container {
        background: url(yourBlurryImage.jpg) no-repeat fixed;
    }
    

    You can see a working example at the following fiddle: http://jsfiddle.net/jTUjT/5/. Try to resize the browser and see that the alignment never fails.


    If only CSS element() was supported by other browsers other than Mozilla's -moz-element() you could create great effects. See this demo with Mozilla.

提交回复
热议问题