gpt4 book ai didi

html - 隐藏的溢出不适用于图像

转载 作者:行者123 更新时间:2023-11-28 15:01:43 24 4
gpt4 key购买 nike

我试过使用 overflow: hidden;对于每个元素,但它似乎没有做任何事情

html 看起来像这样,显示是并排放置 2 个 div(对于较小的屏幕,堆叠在顶部)。左侧的 div 也将位于右侧的 div 之上。我也有屏幕截图和 fiddle 。

.sec {
background-color: red;
min-height: 100vh;
overflow: hidden;
}

.sec2 {
background-color: blue;
min-height: 100vh;
overflow: hidden;
}

.img1 {
max-width: 100%;
position: absolute;
}

.img1 {
z-index: 1;
}

.leftCol {
z-index: 10;
width: 50%;
}

.info-row {
display: flex;
flex-direction: row;
margin-left: 10vw;
margin-right: 200px;
}

.rightCol {
width: 50%;
}
<section class="sec">
<div class="info-row">
<div class="leftCol info-column">
<h1>haheaheh</h1>
<p>teataetetat</p>
</div>
<div class='rightCol info-column'>
<img class="img1" src='https://kasonbloom.files.wordpress.com/2017/08/lamb-2.jpg' />
</div>
</div>
</section>

<section class="sec2">
<div class="info-row">
<div class="leftCol info-column">
<h1>asdfasdfasdf</h1>
<p>basfbasdfbasdfba</p>
</div>
<div class='rightCol info-column'>
</div>
</div>
</section>

enter image description here

https://jsfiddle.net/gtrnrd9r/2/将结果 View 保持在图像突破该部分的位置

最佳答案

Add position:relative; to your outer section .sec and it will work fine.

.sec {
background-color: red;
min-height: 100vh;
overflow: hidden;
position:relative;
}

.sec2 {
background-color: blue;
min-height: 100vh;
overflow: hidden;
}

.img1 {
max-width: 100%;
position: absolute;
}

.img1 {
z-index: 1;

}

.leftCol {
z-index: 10;
width: 50%;
}

.info-row {
display: flex;
flex-direction: row;
margin-left: 10vw;
margin-right: 200px;
}

.rightCol {
width: 50%;
}
<section class="sec">
<div class="info-row">
<div class="leftCol info-column">
<h1>haheaheh</h1>
<p>teataetetat</p>
</div>
<div class='rightCol info-column'>
<img class="img1" src='https://kasonbloom.files.wordpress.com/2017/08/lamb-2.jpg' />
</div>
</div>
</section>

<section class="sec2">
<div class="info-row">
<div class="leftCol info-column">
<h1>asdfasdfasdf</h1>
<p>basfbasdfbasdfba</p>

</div>
<div class='rightCol info-column'>
</div>
</div>
</section>

关于html - 隐藏的溢出不适用于图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50004556/

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