【发布时间】:2018-10-04 21:14:03
【问题描述】:
我尝试过使用溢出:隐藏;对于每个元素,但它似乎没有做任何事情
html 看起来像这样,显示是让 2 个 div 并排显示(堆叠在顶部以用于较小的屏幕)。左侧 div 也将位于右侧 div 的顶部。我也有屏幕截图和小提琴。
.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>
https://jsfiddle.net/gtrnrd9r/2/ 将结果视图保留在图像突破该部分的位置
【问题讨论】:
-
在您的
sectionCSS 中,minHeight应该是min-height,paddingTop应该是padding-top。请尽量保持一致的缩进。 -
我不确定你在哪里看到我有 minHeight 和 paddingTop,但我用整齐的缩进重新发布了小提琴
-
我说的是您在此处发布的代码,而不是小提琴。 ;)
-
哦,抱歉,我将它的前端反应样式转换为常规样式