gpt4 book ai didi

html - 从盒子 1 后面显示盒子 2

转载 作者:行者123 更新时间:2023-11-28 02:29:21 25 4
gpt4 key购买 nike

我想从 box1 的后面显示我的 box2。

我可以使用 position: relative;.box1 中。

但是,当我在我的元素中使用那个位置时,我遇到了另一个问题。

如何显示 .box2 从后面 .box1 没有设置 position: relative; 放入 .box1?

.main {
height: 100%;
}

#box1 {
background: red;
height: 200px;
width: 100px;
z-index: 999;
}

#box2 {
position: relative;
padding-top: 100px;
padding-bottom: 79px;
color: white;
margin-top: -200px;
margin-left: 110px;
background: black;
heigth: 200px;
width: 100px;
z-index: 1;
}

.animated {
animation-duration: 1s;
animation-fill-mode: both;
}

@keyframes slideInLeft {
from {
transform: translate3d(-100%, 0, 0);
visibility: visible;
}

to {
transform: translate3d(0, 0, 0);
}
}
.slideInLeft {
animation-name: slideInLeft;
}
<div class="main">
<div id="box1">
</div>
<div id="box2" class="animated slideInLeft">
Some text
</div>

</div>

最佳答案

将 z-index 更改为 -1

.main {
height: 100%;
}

#box1 {
background: red;
height: 200px;
width: 100px;
z-index: 999;
}

#box2 {
position: relative;
margin: auto;
color: white;
margin-top: -200px;
margin-left: 110px;
background: black;
height: 200px;
width: 100px;
z-index: -1;
}

.animated {
animation-duration: 1s;
animation-fill-mode: both;
}

@keyframes slideInLeft {
from {
transform: translate3d(-100%, 0, 0);
visibility: visible;
}
to {
transform: translate3d(0, 0, 0);
}
}

.slideInLeft {
animation-name: slideInLeft;
}
<div class="main">

<div id="box1">
</div>
<div id="box2" class="animated slideInLeft">
Some text
</div>

</div>

关于html - 从盒子 1 后面显示盒子 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47786401/

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