我玩弄过你的密码。
为了总是有一些填充物,不管有多宽,你必须使用文本的相对位置和绝对位置的图像。由于衬垫底部的宽度不同,所以我建议您
将图像作为
background-image
并将背景图像的大小设置为
cover
在CSS中
,这样无论屏幕有多宽/窄/高/短,都不会有间隙。我尝试了80%宽度的给定代码,并将填充设置为33%(我没有将背景图像代码放入),50%,初始宽度,不需要底部填充。
由于CSS结构的原因,代码片段不会运行,但我还是将其包含进来以供将来参考。这里是一个
codepen link
和A
second one
希望这有帮助
.item {
position: relative;
&__wrapper {
max-width: 50%;
position: relative;
min-height: 100vh;
}
&__img {
img {
top: 0px;
position: absolute;
width: 100%!important;
}
}
&__text {
top: 0px;
position: relative;
min-height: 100vh;
background: rgba(238, 238, 238, 0.5);
padding-right: 50px;
padding-left: 50px;
padding-top: 30px;
//padding-bottom:33vh at 80%;
z-index: 0;
display: flex;
flex-direction: column;
align-items: top;
justify-content: center;
}
&__boxes {
background-color: #ccc;
display: flex;
position: relative;
bottom: 0px;
}
}
.col {
&-padding {
padding: 16px 16px 5px 16px;
}
&-m-12 {
width: 100%;
}
}
@media (min-width: 1024px) {
.col {
&-t-6 {
width: 50%;
}
}
}
<div class="item__wrapper">
<div class="item">
<div class="item__img">
<picture>
<source media="(min-width: 1300px)" srcset="https://placeimg.com/1000/480/nature">
<source media="(min-width: 1024px)" srcset="https://placeimg.com/960/480/nature">
<img src="https://placeimg.com/640/480/nature" alt="Flowers" style="width:auto;">
</picture>
</div>
<div class="item__text">
<h3>Some title</h3>
<p>Efficiently communicate sticky quality vectors after compelling growth strategies. Compellingly scale future-proof content rather than enterprise users. Uniquely build scalable applications vis-a-vis performance based functionalities. Monotonectally
procrastinate. Compellingly scale future-proof content rather than enterprise users. Uniquely build scalable applications vis-a-vis performance based functionalities. Monotonectally procrastinate.</p>
</div>
</div>
<div class="item__boxes">
<div class="col-m-12 col-t-6 col-padding">
<div>Some Title</div>
<div>Enthusiastically incubate diverse initiatives without multifunctional strategic theme areas.</div>
</div>
<div class="col-m-12 col-t-6 col-padding">
<div>Globally Title</div>
<div>Globally impact integrated infomediaries via seamless mindshare. </div>
</div>
<div class="col-m-12 col-t-6 col-padding">
<div>Distinctively Title</div>
<div>Distinctively strategize long-term high-impact ideas whereas client-centered leadership skills.</div>
</div>
</div>
</div>