需要 CSS 专家 - 我的页面设计中的 Z-Index 堆栈问题

发布于 2024-08-28 14:34:02 字数 899 浏览 10 评论 0原文

基本上我在 Z-Index 方面遇到了一些问题。虽然我在 CSS 方面并不出色,但我认为我相当不错,但确实无法解决这个问题。

您将在 URL 中看到...

http://howcode.com/code/

...我的问题是返回的“热门”结果中的链接不可点击或任何其他内容。我得出的结论是,这是由于他们的 Z-Index 被搞乱了。我必须摆弄和调整 Z-Index 才能让选项卡 - 热门、最高评价、精选等 - 显示在 codebg div 上方。

当我调整 Z-Index 以使结果绝对位于顶部时,它们表现得像正常一样 - 可以选择文本、悬停评级图像等。然而,这样做的缺点是我的“热门”、“最高评价”、“精选”选项卡全部放置在返回结果的背景图像下方。

如果有人可以发布解决方法或对我的 CSS 进行更改,我将不胜感激。

请不要忘记这是一个测试站点和设计,任何其他 URL 可能都不起作用,我还没有上传任何数据库配置或其他什么!

附上几个屏幕截图来澄清我的意思:

  1. 这就是我想要发生的事情(实际上并不是这个屏幕截图中的链接不可点击,只是为了演示我的观点):

  2. 这就是我调整 Z-Index 属性时发生的情况(我不想要这样!): 哦不!

谢谢大家!

Basically I'm having some problems with Z-Index. Although I'm not amazing at CSS I would reckon I was reasonably good, but really can't work this out.

You'll see at the URL...

http://howcode.com/code/

... that my problem is that links in the returned 'Popular' results aren't clickable or anything. I've concluded this is due to their Z-Index being messed up. I had to fiddle and tweak with Z-Index to get the tabs - Popular, Top Rated, Featured etc. - to show above the codebg div.

When I adjusted the Z-Index so that the results were definitely on top, they acted as normal - text could be selected, the ratings images hovered, etc. etc. However the downside to this was that my Popular, Top Rated, Featured tabs were all placed BENEATH the background image for the returned results.

If anyone can post a workaround or alteration to my CSS that would be much appreciated.

Please don't forget this is a test site and design and any other URLs are likely not to work, I haven't uploaded any database configs yet or whatever!

Attached are a couple of screenshots to clarify what I mean:

  1. This is what I WANT to happen (not that in actual fact in this screenshots link aren't clickable, just to demo my point though):
    what i want

  2. This is what DOES happen when I adjust the Z-Index properties (I don't want this!):
    oh noes!

Thanks y'all!

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

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

发布评论

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

评论(3

末骤雨初歇 2024-09-04 14:34:02

您需要

z-index: -1 !important;

从您的 .codebg 类中删除此:,这将导致上面的#2 屏幕截图。 (顺便说一句,子级的 z-index 不能高于父级,因此 .codbg 内的所有内容都是 -1,位于页面后面)然后,您需要修复选项卡图像:) 问题不在于它们位于背景后面,而在于它们是透明的,并且在较暗的背景上看起来更暗。这是图像(一旦更新,直接指向它,此答案可能会发生变化):

alt text http: //howcode.com/images/tabs.png

由于白色背景,它们在这里看起来很好,但是如果您在编辑器中打开它们,您会看到它们是透明的,只需将三个选项卡设为透明即可完全(或至少更加)不透明,因为这似乎就是您所追求的。

You need to remove this:

z-index: -1 !important;

From your .codebg class, which will result in your #2 screenshot above. (As a side note the children can't have a higher z-index than their parent, so everything inside .codbg is -1, behind the page) Then, you need to fix the tab images :) The problem is not that they're behind the background, it's that they're transparent, and look darker on top of a darker background. Here's the image (may change in this answer once you update it, pointing directly to it):

alt text http://howcode.com/images/tabs.png

They look fine here because of the white background, but if you open them up in an editor, you'll see they're transparent, just make the the three tabs fully (or at least more) opaque since that seems to be what you're after.

终陌 2024-09-04 14:34:02

这不是最好的解决方案,但就这样。

  1. 在内容 div 内将选项卡 div 移动到 codebg 之后,这样


变成这样


然后添加到#tabs

位置:绝对;顶部:232px;

到#content

顶部填充:53px;

这是一个快速而肮脏的修复。否则你必须重新考虑你的整个布局

not the best solution but here it goes.

  1. inside the content div move tabs div after codebg so this
<div id="content">
  <div id="tabs">
  </div>
  <div id="codebg">
  </div>
</div

becomes this

<div id="content">
  <div id="codebg">
  </div>
  <div id="tabs">
  </div>
</div

then add to #tabs

position:absolute; top:232px;

to #content

padding-top:53px;

this is a quick and dirty fix. otherwise you have to rethink your whole layout

不甘平庸 2024-09-04 14:34:02

您还可以将 code-bg 中的 background-image 放在 content 上,并调整内容的宽度和边框半径

You could also put your background-image from code-bg on content instead, and adjust content's width and border-radius

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