One alternative method involves utilizing a CSS pseudo ::before
element that adjusts its height in sync with the col-lg-6
container.
#main {
background: lightgreen;
height: 100vh;
}
#main > .row {
height: 100vh;
}
.left {
background: red;
position: relative;
top: 50%;
transform: translateY(-50%);
}
.left:before {
left: -999em;
background: red;
content: '';
display: block;
position: absolute;
width: 999em;
top: 0;
bottom: 0;
}
<div class="container" id="main">
<div class="row">
<div class="col-lg-6 left">
..
</div>
</div>
</div>
Another approach is to use an absolutely positioned .container-fluid
(full-width) behind the content within the .container
, acting as a "ghost" element...
.abs {
position: absolute;
right:0;
top:0;
bottom:0;
z-index: 1;
}
<div class="container">
<div class="row">
<div class="col-sm-6">
<h4>Content</h4>
</div>
<div class="col-sm-6">
<!-- space over image -->
</div>
</div>
</div>
<div class="container-fluid abs">
<div class="row h-100">
<div class="col-sm-6 h-100">
<!-- empty spacer -->
</div>
<div class="col-sm-6 right">
<img src="//placehold.it/1000x400">
</div>
</div>
</div>
(Bootstrap 4)
Related questions:
Achieving Two Columns with Different Background Colors That Extend to Screen Edge
Illustration featuring Image on the Right
Illustration showcasing Image on the Left
Extending an Element Beyond the Bootstrap Container