给予 Cufóna 更高的 z-index
我有一个有趣的目标,希望在您的帮助下能够实现。
我有这样的 HTML 结构:
<li>
<span class="buttonHighlight"></span>
<a href="#buy" class="button">BUY NOW</a>
</li>
HTML + 一些 CSS 行给了我这个:
IMG 1 (见下文)
如您所见,span.buttonHighlight 与按钮本身重叠。现在,有趣的部分来了:该按钮是一个带有 cufonized 文本的简单锚标记,它有一些 CSS 样式,赋予它圆形按钮背景。 因此,我想要实现的是将 3 个元素(CSS 背景、cufonized 文本和突出显示)按以下顺序放置:
IMG 2(见下文)
到目前为止我尝试过的是分别针对每个元素: 为 span.buttonHighlight,CSS 驱动的背景/框为a.button 和 cufonized 文本为 a.button .cufon 。幸运的是,a.button .cufon 正确显示;你可以在FireBug中看到它:
IMG 3(见下文)
但是,添加优于span.buttonHighlight(100)z索引的z索引(101)并没有帮助,即突出显示仍然与文本重叠。
您可以在这里找到与此案例相关的所有 CSS 样式:pastie [dot] org/1478291
我真的非常感谢您提供的任何帮助和您的时间。
非常感谢!
克里斯
**PS。由于我不允许发布图像且只有 1 个超链接,因此我堆叠了以下 3 张图像:
I have an interesting goal that hopefully, with your help, will be achieved.
I have this HTML structure:
<li>
<span class="buttonHighlight"></span>
<a href="#buy" class="button">BUY NOW</a>
</li>
That HTML + a few CSS lines gives me this:
IMG 1 (see below)
As you can see, the span.buttonHighlight is overlapping the button itself. Now, here comes the interesting part: The button is a simple anchor tag with cufonized text, that has a few CSS styles which give it that rounded-button background. Hence, what I want to achieve, is putting the 3 elements (CSS background, cufonized text and Highlight) in this order:
IMG 2 (see below)
What I've tried so far was to aim at each element separately: The <span class="buttonHighlight"></span>
as span.buttonHighlight, the CSS-driven background/box as a.button and the cufonized text as a.button .cufon . And luckily, the a.button .cufon is properly displaying; you can see it in FireBug:
IMG 3 (see below)
However, adding a z-index (of 101) that is superior to the z-index of span.buttonHighlight (100) did not help, i.e. the Highlight still overlapped the text.
You can find all the CSS styles relevant to this case here: pastie [dot] org/1478291
I really, really appreciate any help provided and your time.
Thank you so much!
Chris
**PS. Since I am not allowed to post images and only 1 hyperlink, i've stacked the 3 images below:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
z-index 仅适用于定位元素,您必须指定 postion:relative,即使这是默认值。试试这个:
和
z-index only works on positioned elements, you must specify postion:relative even if that is the default. Try this:
and