using a div to blur an image behind it? [duplicate

2019-01-08 21:49发布

This question already has an answer here:

Is it possible to code a div to enable it to blur whatever image is under it?

something like this:

enter image description here

Could this be done somehow with -webkit maybe?

2条回答
做自己的国王
2楼-- · 2019-01-08 22:25

Unfortunately this can't be done purely using CSS. Although webkit-filter supports blur, it doesn't support blurring anything other than the element that it applies to.

There is a more hacky way to do this, described here - http://css-tricks.com/blurry-background-effect/

查看更多
小情绪 Triste *
3楼-- · 2019-01-08 22:41

Not with CSS on its own, but you can pull a similar effect off with Canvas and the StackBlurforCanvas library. See this

UPDATE: Looks like backdrop-filter was recently introduced to Webkit nightly, so eventually we'll be able to do this with CSS only. Yay!

查看更多
登录 后发表回答