gpt4 book ai didi

html - 如何将文本放在图案叠加层 CSS 之上

转载 作者:太空宇宙 更新时间:2023-11-04 11:45:35 24 4
gpt4 key购买 nike

可能很简单,但无法让它发挥作用。我已经成功地用图案覆盖背景图像,但现在标题也放在图案后面。我已经尝试使用 z-index(如下面的代码所示),但它仍然无法正常工作。有什么想法吗?

结果

enter image description here

Index.html

<div class="content">
<div class="subheader">
<div class="container">
<h1>PROVIDE <br>CREATIVITY IN <br> YOUR BUSINESS</h1>
</div>
<div class="pixel-overlay"></div>
</div>
</div>

样式.css

.content .subheader {
width: 100%;
height: auto;
display: inline-block;
padding: 130px 0 0;
background: url(../images/landing.jpg) no-repeat 50% 0%;
position: relative;
background-attachment: fixed;
text-align: center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
-ms-behavior: url(../js/backgroundsize.htc);
}

.content .subheader:after {
content: "";
background: url(../images/pattern/pattern.png) repeat;
background-size: 90%;
background-attachment: fixed;
opacity: 0.2;
top: 0;
left: 0;
bottom: 0;
right: 0;
position: absolute;
z-index: 0;
}

.content .subheader h1 {
margin-top: 25%;
z-index: 100;
}

最佳答案

尝试将 position: relative; 添加到标题中,如下所示:

.content .subheader h1 {
margin-top: 25%;
z-index: 100;
position: relative;
}

关于html - 如何将文本放在图案叠加层 CSS 之上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31021738/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com