Bootstrap version >= 4.1.1.
On its parent, add the d-flex
and flex-column
classes. That means you must remove the d-sm-block
class because in the presence of d-sm-block
, d-flex
does not work. And then, add the flex-grow-1
to the two row
s.
There are two rows here and they take half of the available space.
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<!-- Main video player -->
<div class="col-12 col-sm-8">
<img class="img-fluid" src="http://via.placeholder.com/730x411">
</div>
<!-- Video Selector -->
<div class="col col-sm-4 d-none d-flex flex-column">
<div class="row flex-grow-1">
<div class="col-sm-3 bg-warning"><img class="img-fluid" src="http://via.placeholder.com/730x411"></div>
<div class="col-sm-9 bg-success">Video One</div>
</div>
<div class="row flex-grow-1">
<div class="col-sm-3 bg-warning"><img class="img-fluid" src="http://via.placeholder.com/730x411"></div>
<div class="col-sm-9 bg-success">Video Two</div>
</div>
</div>
</div>
</div>
Check this pen on codepen or run the code snippet.
There is one row here but still it takes all the available space.
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.css" rel="stylesheet" />
<div class="container">
<div class="row">
<!-- Main video player -->
<div class="col-12 col-sm-8">
<img class="img-fluid" src="http://via.placeholder.com/730x411">
</div>
<!-- Video Selector -->
<div class="col col-sm-4 d-none d-flex flex-column">
<div class="row flex-grow-1">
<div class="col-sm-3 bg-warning"><img class="img-fluid" src="http://via.placeholder.com/730x411"></div>
<div class="col-sm-9 bg-success">Video One</div>
</div>
</div>
</div>
</div>
FYI, If you want that one of the rows takes as much space as it needs and the other takes all the available space, use flex-grow-1
on the latter one only.
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.css" rel="stylesheet" />
<div class="container">
<div class="row">
<!-- Main video player -->
<div class="col-12 col-sm-8">
<img class="img-fluid" src="http://via.placeholder.com/730x411">
</div>
<!-- Video Selector -->
<div class="col col-sm-4 d-none d-flex flex-column">
<div class="row flex-grow-1">
<div class="col-sm-3 bg-warning"><img class="img-fluid" src="http://via.placeholder.com/730x411"></div>
<div class="col-sm-9 bg-success">Video One</div>
</div>
<div class="row ">
<div class="col-sm-3 bg-warning"><img class="img-fluid" src="http://via.placeholder.com/730x411"></div>
<div class="col-sm-9 bg-success">Video Two</div>
</div>
</div>
</div>
</div>
Bootstrap version 4.
Bootstrap version 4 does not have the flex-grow-1
class. In that case, use the code below.
.flex-grow-1 {
-ms-flex-positive: 1 !important;
flex-grow: 1 !important;
}