【发布时间】:2019-02-22 01:05:22
【问题描述】:
任何使列内的 div 能够扩展到右(或左)边缘的技巧?我需要坚持使用固定容器而不是流体容器。此外,由于 CMS,“扩展块”需要保留在标记中(不能是 CSS 伪元素)。
https://codepen.io/mwmd/pen/eLPxOX
<div class="container">
<div class="row">
<div class="col-sm-7">
<p>How can I get that div to extend to viewport right while maintaining its left edge to the Bootstrap column?</p>
</div>
<div class="col-sm-5">
<div class="extend-me">
<img src="https://via.placeholder.com/350x150"/>
</div>
</div>
</div>
</div>
.container {
background-color: #999;
}
.extend-me {
background-color: darkred;
height: 300px;
}
.extend-me img {
object-fit: cover;
width: 100%;
height: 300px;
}
没有回答 Extend an element beyond the bootstrap container 因为这个解决方案使用了伪元素。
没有回答 Extend bootstrap row outside the container 因为此解决方案仅适用于 50% 50% 的拆分。
【问题讨论】:
标签: css bootstrap-4