简体   繁体   English

CSS / jquery模糊叠加效果示例

[英]CSS/jquery blur overlay effect example

If you take a look at this website, when you scroll down you'll notice that there is some sort of blur overlay effect 如果您浏览此网站,向下滚动时会注意到存在某种模糊叠加效果

https://medium.com/war-is-boring https://medium.com/war-is-boring

I had a look at the source code in Chrome but I couldn't find the exact CSS used to achieve this effect. 我查看了Chrome中的源代码,但是找不到用于实现此效果的确切CSS。 Does anyone have an idea or suggestion on what techniques is used to achieve this effect? 是否有人对使用什么技术来达到这种效果有想法或建议? I'm planning on using it on a mobile menu. 我打算在移动菜单上使用它。

Thanks 谢谢

The page you're referencing uses data-* attributes and some Javascript to cleverly switch the background image to a blurred one. 如果引用数据-使用*属性和一些JavaScript的网页背景图像巧妙地切换到模糊的。 This explains why you couldn't find the CSS: 这解释了为什么找不到CSS的原因:

<div class="image-full-bleed is-usingCanvas" data-scroll="blur-cover" data-image-url="https://d262ilb51hltx0.cloudfront.net/fit/c/1200/960/gradv/29/81/60/darken/25/1*fDLP8pfTZX3cAQB0J6a72g.jpeg" data-image-blur-url="https://d262ilb51hltx0.cloudfront.net/fit/c/1200/960/gradv/29/81/40/darken/50/blur/50/1*fDLP8pfTZX3cAQB0J6a72g.jpeg"><div class="image-src picker-target" style="background-image: url('https://d262ilb51hltx0.cloudfront.net/fit/c/1200/960/gradv/29/81/60/darken/25/1*fDLP8pfTZX3cAQB0J6a72g.jpeg')"></div></div>

Depending on your needs, you may be able to use Filter - Blur : 根据您的需要,您可以使用“ 滤镜 - 模糊”

  -webkit-filter: blur(5px);
  -moz-filter: blur(5px);
  -o-filter: blur(5px);
  -ms-filter: blur(5px);
  filter: blur(5px);

If you clearly layout what you're looking for I may be able to help point you in the right direction. 如果您清楚地确定要寻找的内容,我可能会帮助您指出正确的方向。

Also, if you don't need the blur effect and just need something semi-transparent the you can use the opacity ( -ms-filter for old IE) value. 另外,如果您不需要模糊效果而只需要半透明的东西,则可以使用opacity (对于旧IE来说是-ms-filter )。

apply blur filter: 应用模糊滤镜:

-webkit-filter: blur(10px); // for chrome
-moz-filter: blur(10px); // for firefox

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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