Extend Bootstrap Row Outside the Container

Bootstrap 4 row extends outside of container

The .row in bootstrap is giving a margin right and left of -15px, override it with a in-line style="margin: auto" and you should be fine.

The aside has a default padding left and right of 15, so in your case you should set the padding-left to 0 making the content fit the grid properly.

<section id="page-content">
<div class="row" style="margin: auto">
<aside class="col-md-3" style="padding-left: 0">
<div class="card mt-3">
<a href="#">
<img class="card-img-top" src="http://via.placeholder.com/200x200" alt="Card image cap">
<div class="card-body">
<p class="card-text">Service</p>
</div>
</a>
</div>

<div class="card mt-3">
<a href="#">
<img class="card-img-top" src="http://via.placeholder.com/200x200" alt="Card image cap">
<div class="card-body">
<p class="card-text">Products</p>
</div>
</a>
</div>

<div class="card mt-3">
<a href="#">
<img class="card-img-top" src="http://via.placeholder.com/200x200" alt="Card image cap">
<div class="card-body">
<p class="card-text">Parts & accessories</p>
</div>
</a>
</div>
</aside>

<article class="main col-md-9 col-sm-12 px-3 mt-3">
<p>This is the main content area</p>
</article>
</div><!--END ROW-->
</section><!--END PAGE CONTENT-->

Extend bootstrap row outside the container

One option is to use a CSS pseudo ::before element that will resize in height along with the col-lg-6..

#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>

http://codeply.com/go/C80RYwhWrc


Another option is to use an absolute position .container-fluid (full-width) behind the content .container that acts as a "ghost"...

.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>

https://codeply.com/go/txUHH72f16 (Bootstrap 4)


Similar questions:

Get Two Columns with different background colours that extend to screen edge

Example with image right

Example with image left

Extend an element beyond the bootstrap container

Extend an element beyond the bootstrap container

Basically, this has already been answered, but I will answer since Bootstrap 4 flexbox is different than the other 3.x answer.

It can be done with pseudo element that extends outside the column:

https://codeply.com/go/tXGn5pdD4A

.bg-colored:before {
right: -999em;
background: #0b3b52;
content: '';
display: block;
position: absolute;
width: 999em;
top: 0;
bottom: 0;
}

Bootstrap column to extend out side of the container

i think i figured it out, instead of using a normal container i would have to use container fluid as i said before but just an offset

<div class="container-fluid">
<div class="row">
<div class="col-sm-offset-2 col-xs-4 first">

</div>
<div class="col-sm-6 second">

</div>
</div>
</div>

Bootstrap 4: Make an object inside of a container column extend to the viewport edge

HTML: on the div with class "extend-me", also add the class "row"
CSS: to extend the inside div to the right, add margin-left to 0 .extend-me { margin-left: 0;}

sample

<div class="container yourOverallContainer">
<div class="row">
<div class="col-sm-7">
<h1> Stack overflow question </h1>
</div>
</div>
</div>

<div class="container-fluid">
<div class="row">
<div class="col-sm-7 thisToBeAlignedToContainer">
<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 row">
<img src="https://via.placeholder.com/350x150"/>
</div>
</div>
</div>
</div>


<div class="container">
<div class="row">
<footer>
<p id='feedback'> without jQuery and .container-fluid, yet completely responsive will be interesting... </p>
</footer>
</div>
</div>


.container {
background-color:#c9efb1;
}

.container-fluid {
background-color: #fff;
}

.extend-me {
background-color: darkred;
height: 300px;
}
.extend-me img {
object-fit: cover;
width: 100%;
height: 300px;
}



mWilson();

$(window).resize(function(){
mWilson();
});

function mWilson(){
$('.thisToBeAlignedToContainer').css('padding-left', $('.yourOverallContainer').css('margin-left'));
}


Related Topics



Leave a reply



Submit