gpt4 book ai didi

html - 为什么我的背景在我的文字前面?

转载 作者:行者123 更新时间:2023-11-27 23:23:12 25 4
gpt4 key购买 nike

为什么我的背景在文字前面?

所以我有这样的 .html 和 .css 文件我尝试了相对位置、绝对位置、固定位置,但输出仍然不是我想要的。

    .main-main-container{
position:absolute;
display: grid;
height: 100vh;
margin:0;
padding:0;

}

.main-container{
display: grid;
//grid-template-rows: minmax(20%,auto) auto minmax(20%,auto) minmax(10%,auto);
grid-template-rows: 1fr 4fr 1fr 40px ;
grid-gap: 0.5em;

}

/*
@keyframes sliding-background{
0%{
background-image: url(../images/Desert.jpg);
}
25%{
background-image: url(../images/Hydrangeas.jpg);
}
50%{
background-image: url(../images/Jellyfish.jpg);
}
75%{
background-image: url(../images/Lighthouse.jpg);
}
100%{
background-image: url(../images/Penguins.jpg);
}

}
*/

.main-container > figure {
animation: imageAnimation 30s linear infinite 0s;
backface-visibility: hidden;
background-size: cover;
background-position: center center;
color: transparent;
height: 100%;
left: 0px;
opacity: 0;
position: absolute;
top: 0px;
width: 100%;
z-index: 0;
margin:0;
padding:0;
}
.main-container > figure:nth-child(1) {
background-image: url('../images/Desert.jpg');
}
.main-container > figure:nth-child(2) {
animation-delay: 6s;
background-image: url('../images/Hydrangeas.jpg');
}
.main-container > figure:nth-child(3) {
animation-delay: 12s;
background-image: url('../images/Jellyfish.jpg');
}
.main-container > figure:nth-child(4) {
animation-delay: 18s;
background-image: url('../images/Lighthouse.jpg');
}
.main-container > figure:nth-child(5) {
animation-delay: 24s;
background-image: url('../images/Penguins.jpg');
}

@keyframes imageAnimation {
0% {
animation-timing-function: ease-in;
opacity: 0;
}
8% {
animation-timing-function: ease-out;
opacity: 1;
}
17% {
opacity: 1
}
25% {
opacity: 0
}
100% {
opacity: 0
}
}

.header-container {
display: grid;
grid-template-columns: 1fr 2fr 1fr;
//background: red;

}

.content-container {
display: grid;
grid-template-columns: 1fr 2fr 1fr;
//background: yellow;
}

.subcontent-container {
display: grid;
grid-template-columns: 1fr 2fr 1fr;
//background: green;
}

.header-container > div,
.content-container > div,
.subcontent-container > div{
border: #222 1px solid;
}

.content{
//background: green;
}

.sub-content{
//background: yellow
}

.footer-container{
//background: pink;
border: #222 1px solid;

}
    <body class="main-main-container">
<div class="main-container">
<figure></figure>
<figure></figure>
<figure></figure>
<figure></figure>
<figure></figure>
<div class="header-container">
<div class="header-left">
Lorem ipsum dolor sit amet.
</div>
<div class="header-center">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Asperiores, quis ducimus sed in exercitationem quae, molestias placeat eius eveniet molestiae repellendus animi dignissimos, non nostrum facere id iste fugit aspernatur est perferendis? Eaque tempora nesciunt deleniti voluptatem ad quisquam voluptatum.
</div>
<div class="header-right">
Lorem ipsum dolor sit amet.
</div>
</div>
<div class="content-container">
<div class="content-left">
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Dolorem amet maiores, voluptatem quibusdam et veritatis repellendus reiciendis dolor facilis assumenda.
</div>
<div class="content-center">
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Dolorem amet maiores, voluptatem quibusdam et veritatis repellendus reiciendis dolor facilis assumenda.
</div>
<div class="content-right">
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Dolorem amet maiores, voluptatem quibusdam et veritatis repellendus reiciendis dolor facilis assumenda.
</div>
</div>
<div class="subcontent-container">
<div class="subcontent-left">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Quaerat, nam.
</div>
<div class="subcontent-center">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Quaerat, nam.
</div>
<div class="subcontent-right">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Quaerat, nam.
</div>
</div>
<div class="footer-container">
<div>
Lorem ipsum dolor sit amet.
</div>
</div>
</div>
</body>

我想要的是我的滑动图形在我的文本后面,所以它成为我的背景图像而不是替换它前面的我的文本。

最佳答案

.main-container > figure{
z-index: -1;
}

working Fiddle

我认为这会让它发挥作用。

关于html - 为什么我的背景在我的文字前面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57903862/

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