简体   繁体   中英

Div blurring its background

I wanted to recreate an effect like on this page: http://goalkicker.com/Angular2Book/

Here's the thing that is interesting: 在此处输入图片说明

I already found on StackOverflow a few topics about that, but some of them reference sources that do not work, some use methods that do not work with Chrome. Basically I did not find any working example.

On the website, which I provided, the div has the following CSS:

#headerBackground {
    width: 100%;
    min-height: 50px;
    position: fixed;
    top: 0px;
    left: 0px;
    background: #ffffff;
    z-index: 3;
    opacity: 0.6;
    box-shadow: 0px 0px 18px 0px #cccccc;
}

his is obviously not enough, the "blur/glass" part is missing. Is it possible to look "deeper" into the website's internals to reveal how it's done?

You have to place a div similar to the following before the tag at the bottom.

This is for header

<div style="left: 0px; z-index: 2; overflow: hidden; top: 0px; position: fixed; width: 1349px; height: 50px;">
    <div style="position: absolute; background-color: rgb(255, 255, 255); filter: blur(10px); z-index: 1; width: 1100px; height: 3672px; left: 125px; top: 90px;">
    </div>
</div>

This is for footer

<div style="left: 0px; z-index: 2; overflow: hidden; bottom: 0px; position: fixed; width: 1369px; height: 80px;">
    <div style="position: absolute; background-color: rgb(255, 255, 255); filter: blur(10px); z-index: 1; width: 1100px; height: 3672px; left: 125px; top: -130px;">
    </div>
</div>

If needed you can change the width of the parent div to 100% instead of exact with generated by js(I think).

And this is how the reference site's blur effect is done.

-webkit-filter: blur(5px); /* Safari 6.0 - 9.0 */

filter: blur(5px);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM