这是我的代码的代码,因为Stack Overflow还不允许SCSS:https://codepen.io/thedonquixotic/pen/dWXOby
我正在尝试创建一个包含英雄形象和h1的部分。
包含部分具有背景渐变。它的z-index设置为1.
包含部分包含img和h1。 img z-index设置为-1,并且过去在渐变背景后面正确呈现。
h1的z-index为2,应该在图像和渐变之上呈现。
我有这个工作,但后来我添加了一个JS视差脚本。我搞定了。 h1等仍然可见,但表现得有些奇怪,所以我注释掉了JS导入,专注于确保我的flex盒设置正确。现在它根本不起作用了!
body div section.hero {
display: flex !important;
width: 100vw;
height: 81vh;
background-repeat: no-repeat;
background-position: center;
background: linear-gradient(to left, rgba(255, 195, 113, 0.5), rgba(255, 95, 109, 0.5));
position: relative;
z-index: 1;
}
body div section.hero div img {
display: flex !important;
width: 100vw;
height: 81vh;
z-index: -1 !important;
flex: 1 1 auto;
}
body div section.hero div.svg-flex {
position: relative;
display: flex !important;
padding: 30px;
flex-direction: column;
justify-content: center;
align-content: center;
align-items: center;
z-index: 2;
}
body div section.hero div.svg-flex .hero-text {
width: 95vw;
top: 30vh;
stroke-miterlimit: 10;
display: flex;
position: relative;
overflow: hidden;
stroke-linejoin: miter;
font-size: 6rem;
fill: none;
stroke: white;
stroke-width: 2.2px;
}
body div section.hero div.svg-flex h1 {
position: relative;
font-family: 'Aller', Arial;
color: white;
text-align: center;
font-size: 3rem;
line-height: 3rem;
text-shadow: 0 2px 2px rgba(0, 0, 0, 0.35);
max-width: 70rem;
margin: 2vh auto 0;
display: flex !important;
flex-direction: column;
justify-content: center;
align-content: center;
align-items: center;
z-index: 2;
}
<section class="hero scene" id="scene" style="display: flex;">
<div class="layer" style="display: flex;" data-depth="0.40"><img src="https://s-media-cache-ak0.pinimg.com/originals/32/93/21/329321959fcaf0d24e2349ccf8c9407a.jpg">
</div>
<div class="svg-flex layer" data-depth="0.80" style="display: flex;">
<h1 class="class-study-title" style="display: flex;"><h1> The Title</h1>
</div>
</section>
答案 0 :(得分:1)
将这些stlyes添加到h1
smallint