给予 Cufóna 更高的 z-index

发布于 2024-10-13 00:54:01 字数 1211 浏览 2 评论 0原文

我有一个有趣的目标,希望在您的帮助下能够实现。

我有这样的 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 张图像:

https: //i.sstatic.net/Upe63.jpg替代文本

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:

https://i.sstatic.net/Upe63.jpg:
alt text

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

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

发布评论

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

评论(1

灰色世界里的红玫瑰 2024-10-20 00:54:01

z-index 仅适用于定位元素,您必须指定 postion:relative,即使这是默认值。试试这个:

span.buttonHighlight {
background: url(assets/images/button_highlight.png) no-repeat top center;
    z-index: 100;
    position: relative;
}

a.button .cufon { 
    z-index: 101;
    position: relative;
}

z-index only works on positioned elements, you must specify postion:relative even if that is the default. Try this:

span.buttonHighlight {
background: url(assets/images/button_highlight.png) no-repeat top center;
    z-index: 100;
    position: relative;
}

and

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