绝对定位叠加忽略 z-index

发布于 2024-11-26 22:38:02 字数 510 浏览 1 评论 0原文

我有以下模板,我正在尝试使用它,我冒昧地为每个 div 添加不同的颜色背景以进行调试,基本上我有三个具有不同背景的 div,并且这些背景需要在中心发光。为此,我尝试设置一个不透明度为 10% 的绝对定位容器。但是它会覆盖所有内容并忽略 z-index。

我知道我错过了一些简单的东西,但我已经关注这个太久了。

http://fwuse.com/n/ 没有发光,颜色不是用于调试的设计。 http://fwuse.com/n/glow.html 添加了 Glow 容器,仅保留菜单出来,其他一切都被隐藏了。 http://fwuse.com/n/glow-opacity.html 不透明的发光容器,请注意没有任何链接可以单击。

I have the following template that I am trying to get working, I have taken the liberty to add different color backgrounds to each div for debugging, basically I have three divs that are different backgrounds and these backgrounds need to have a glow in the center. To do this I tried setting an absolutely positioned container with 10% opacity. However it overlays everything and ignores z-index.

I know I am missing something simple, but I have been looking at this for too long.

http://fwuse.com/n/ No glow, the colors are not the design they are their for debugging.
http://fwuse.com/n/glow.html Glow container added, only the menu sticks out, everything else is hidden.
http://fwuse.com/n/glow-opacity.html Glow container with opacity, notice none of the links can be clicked.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

纵山崖 2024-12-03 22:38:02

为什么不直接使用 CSS 来实现发光效果呢?

#radial-center {
  /* fallback */
  background-color: #2F2727;
  background-position: center center;
  background-repeat: no-repeat;

  /* Safari 4-5, Chrome 1-9 */
  /* Can't specify a percentage size? Laaaaaame. */
  background: -webkit-gradient(radial, center center, 0, center center, 460, from(#1a82f7), to(#2F2727));

  /* Safari 5.1+, Chrome 10+ */
  background: -webkit-radial-gradient(circle, #1a82f7, #2F2727);

  /* Firefox 3.6+ */ 
  background: -moz-radial-gradient(circle, #1a82f7, #2F2727);

  /* IE 10 */ 
  background: -ms-radial-gradient(circle, #1a82f7, #2F2727);

  /* IE < 8 Linear gradient fallback */
  filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#1a82f7, endColorstr=#2F2727, GradientType=1)";

  /* IE 8/9 Linear gradient fallback */
  -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#1a82f7, endColorstr=#2F2727, GradientType=1)";
  /* Opera cannot do radial gradients yet */

}

演示:http://jsfiddle.net/AlienWebguy/49d5g/

Why not just use CSS for your glow?

#radial-center {
  /* fallback */
  background-color: #2F2727;
  background-position: center center;
  background-repeat: no-repeat;

  /* Safari 4-5, Chrome 1-9 */
  /* Can't specify a percentage size? Laaaaaame. */
  background: -webkit-gradient(radial, center center, 0, center center, 460, from(#1a82f7), to(#2F2727));

  /* Safari 5.1+, Chrome 10+ */
  background: -webkit-radial-gradient(circle, #1a82f7, #2F2727);

  /* Firefox 3.6+ */ 
  background: -moz-radial-gradient(circle, #1a82f7, #2F2727);

  /* IE 10 */ 
  background: -ms-radial-gradient(circle, #1a82f7, #2F2727);

  /* IE < 8 Linear gradient fallback */
  filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#1a82f7, endColorstr=#2F2727, GradientType=1)";

  /* IE 8/9 Linear gradient fallback */
  -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#1a82f7, endColorstr=#2F2727, GradientType=1)";
  /* Opera cannot do radial gradients yet */

}

Demo: http://jsfiddle.net/AlienWebguy/49d5g/

池木 2024-12-03 22:38:02

如果您可以使内容 div 没有背景颜色(背景:透明?)并具有 z-index 3,并且底层的“10% 不透明度”div 具有 z-index 2,那么它将起作用。我不确定background:transparent是否是CSS中的一个属性;)

If you can make the content div not have a background color(background:transparent ?) and have z-index 3, and the underlying "10% opacity" div have z-index 2, it will work. I am not sure if background:transparent is a property in CSS however ;)

纵情客 2024-12-03 22:38:02

#content-bg 的 z-index 低于覆盖整个页面的辉光,因此消耗了内容的所有点击。将 #content-bg 的 z-index 更改为 3 似乎可以将其置于足够靠前的位置,以便可以单击,同时不会影响发光效果。

#content-bg has a lower z-index than the glow which is covering the whole page, therefore consuming all the clicks for the content. Changing the z-index for #content-bg to 3 seemed to bring it to the front enough to be clicked while not affecting the glow effect.

岁吢 2024-12-03 22:38:02

我修复了它,我必须设置 #pagecontainer z-index 并将背景 div 设置为 z-index:auto。我将页眉设置为 z-index: 501,内容设置为 z-index: 502,页脚设置为 z-index: 503,#glow 设置为 z-index: 1。

尽管这很令人困惑,但它有效,知道为什么吗?

http://fwuse.com/no/

I fixed it, I had to set the #pagecontainer z-index and set the background divs to z-index:auto. I set header to z-index: 501, content to z-index: 502 and footer to z-index 503, #glow was set to z-index: 1.

As confusing as this is, it works, any idea why?

http://fwuse.com/no/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文