gpt4 book ai didi

html - CSS - 缩小背景 div

转载 作者:行者123 更新时间:2023-11-28 05:13:57 25 4
gpt4 key购买 nike

我需要做以下事情:
enter image description here

第二部分的内容应与第一部分和第三部分重叠。
我设法将 content-div 移到一侧,或者我将第一部分或第二部分与“position:relative”和负的顶部/底部值重叠。

是否有可能以某种方式缩小背景包装器 div 但在某种程度上,它不会影响内部包装器内容 div ?

我简化了图像。这些部分具有倾斜的伪元素(之后和之前)。不知道,这是否重要。

使用这段代码,我设法将我的内容部分移动到底部或顶部:

.site-container {
position: relative;
bottom: -100px;
}

但主要部分仍然和内部内容一样高。

最佳答案

你可以简单地position两个 <div>取决于第二部分的元素不受容器大小的影响:

section {
display: block;
width: 50vw;
height: 30vh;
border: 2px solid;
position: relative;
}

div {
position: absolute;
left: 15vw;
width: 20vw;
height: 10vh;
border: 1px solid;
background: white;
z-index: 2;
}

div:first-child {
top: -5vh;
}

div:nth-child(2) {
bottom: -5vh;
}
<section>1</section>
<section>2
<div>2.1</div>
<div>2.2</div>
</section>
<section>3</section>

关于html - CSS - 缩小背景 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50020886/

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