如何调暗网页以将注意力集中在横幅上? (网页上的暗亮效果)
我想知道在某些网页中如何创建这种效果:
加载网页时,带有关闭按钮的横幅广告显示在最上层,实际网页显示在下层;网页完全变暗,注意力的焦点自然落在带有关闭按钮的横幅广告上。 点击广告中的关闭按钮后,实际网页会立即显示,但现在又恢复到原来的亮度。
嗯,这只是一个例子,我知道这种展示广告的做法令人讨厌。
我的问题是 - 如何在网页上获得暗淡效果?
PS:
- 我知道css中的z-index,所以我只需要知道调光部分。
- 如果可能的话,我正在寻找基于 css 的解决方案(或者换句话说,不使用任何脚本(如 js)的解决方案)。
谢谢你们。
I was wondering on how this effect is created in certain webpages :
On loading the webpage, a banner ad with a close button is displayed as the topmost layer, and the actual webpage is displayed as the lower layer; the webpage being completely dimmed out, so that the focus of attention naturally falls on the banner ad with close button.
And on clicking this close button in the ad, the actual webpage is displayed immediately, but now, back to its original brightness.
Well, that was just an example, I know such practices of displaying ads are irksome.
And my question here is - How do you get that dim-and-bright effect on your webpage?
PS:
- I know about the z-index in css, so I just need to know the dimming part.
- I'm looking for a css based solution (or rephrasing that, solution without the use of any scripting like js), if its possible.
Thanks guys.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像这个之类的东西? 非常少的脚本。
HTML
jQuery
CSS
Something like this? Very minimal scripting.
HTML
jQuery
CSS
您可以使用 CSS 中的 :target 选择器和不透明度来执行此操作,但这两种方法在大多数浏览器中都不可用。
相反,您将必须使用 javascript 来显示灰色框。
通常,您会使用绝对定位的 100% 宽度和高度框,其背景颜色为 rgba,并带有透明 png 后备。
像这样设计它就可以了:
然后使用一些简单的 jQuery 来显示它并删除它。
You can do this using the :target selector in CSS and opacity, but both are not available in most browsers.
Instead, you are going to have to use javascript to make the dimed box appear.
Usually you'd use a absolutely positioned 100% width and height box with a background color that's rgba with a transparent png fallback.
Styling it like this will work:
Then use some simple jQuery to show it and remove it.