Bootstrap 4 : Each row fill the same amount of height - css

I'm making a preloader and i'm struggling with the rows. I want my grey rectangle to be filled with 3 rows of 33% height.
Then I need:
in the row 1, a svg logo
in the row 2, a loader
in the row 3, some text
Here's what I want:
Here's my code :
#loader-modal {
width: 100vw;
height: 100vh;
position: fixed;
background-color: rgba(0,0,0, 0.9);
z-index: 100000;
}
.rectangle-chargement {
width: 25%;
height: 50%;
top: 25%;
left: 37.5%;
position: absolute;
background-color: #E2E2E2;
border-radius: 0.15rem;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<div id="loader-modal">
<div class="d-flex justify-content-center mx-auto rectangle-chargement">
<div class="container">
<div class="row">
<div class="col-12">
<!--<svg width="100%" >My SVG</svg>-->
</div>
</div>
<div class="row">
<div class="col-12">
<div class="d-flex justify-content-center" id="loader-circulaire">
<div id="chargement-loader"></div>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<p class="d-flex justify-content-center mx-auto patienter-chargement">Veuillez patienter ...</p>
</div>
</div>
</div>
</div>
</div>
Do you guys know a cleaner way to do it ? (and a working one of course)

You can certainly hard code the heights, but since you ask if there is any cleaner way to do it, my opinion is to use flexbox with column flow direction, and let flexbox children grow by setting their flex-grow to 1.
This way doesn't require you to hard code the height for each row, and allows you to have as many rows as you "want".
<div class="rectangle-chargement d-flex flex-column">
<div class="rectangle-chargement-row flex-grow-1">
Logo
</div>
<div class="rectangle-chargement-row flex-grow-1">
Loader
</div>
<div class="rectangle-chargement-row flex-grow-1">
Some text
</div>
</div>
demo: https://jsfiddle.net/davidliang2008/sngkbLcq/32/
If you want to "centralize" the content in each row, you can mark each row as flexbox as well, and set its justify-content and align-items to center.
<div class="rectangle-chargement d-flex flex-column">
<div class="rectangle-chargement-row flex-grow-1
d-flex justify-content-center align-items-center">
Logo
</div>
<div class="rectangle-chargement-row flex-grow-1
d-flex justify-content-center align-items-center">
Loader
</div>
<div class="rectangle-chargement-row flex-grow-1
d-flex justify-content-center align-items-center">
Some text
</div>
</div>
demo: https://jsfiddle.net/davidliang2008/sngkbLcq/36/

Related

resizing and rounded image on a bootstrap-5 card

I want to resize and rounded the image in a bootstrap-5 card but i don't know how to do that using bootstrap-5 or css3, I want the image to be smaller and rounded on a center of this card.
My Template:
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css"
rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
crossorigin="anonymous">
<div class="container">
<div class="row justify-content-center">
<div class="col">
<div class="card text-center">
<img class="rounded" src="https://3.imimg.com/data3/LE/LH/GLADMIN-37134/school-badges-500x500.jpg" alt="">
<h1 class="text-primary">{{board.school_name}}</h1>
<p>{{board.school_address}}, {{board.location}}</p>
<p>P O Box: {{board.p_o_box}}</p>
</div>
</div>
</div>
</div>
your image is a bad choice as it has a white border around the actual graphic. but see here. i added a .thumb class with a width/height. a align-items-center on the .row and a .rounded-circle on the image.
.thumb {
width: 100px;
height: auto; // if the image is square, this will be 100px automatically
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css"
rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
crossorigin="anonymous">
<div class="container">
<div class="row justify-content-center">
<div class="col">
<div class="card align-items-center">
<img class="rounded-circle thumb" src="https://dummyimage.com/300x300/000/fff.jpg" alt="ff">
<h1 class="text-primary">{{board.school_name}}</h1>
<p>{{board.school_address}}, {{board.location}}</p>
<p>P O Box: {{board.p_o_box}}</p>
</div>
</div>
</div>
</div>

How to create white space between columns without left and right gutter?

I want to create a specified amount of space between columns. So I created this based on the answers I already had. But this has an overflow to the right. I want to eliminate this overflow itself because I can't specify overflow: hidden due to interference of other components:
.row {
margin: 0 -25px;
}
.col {
padding: 0 25px;
min-width: 0;
}
div {
overflow-wrap: break-word;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
<div class="container-fluid p-0">
<div class="row">
<div class="col">
<div class="w-100 p-3 border bg-light">Looooooooooooooooooooooooooooooooooooooooooooooooong text</div>
</div>
<div class="col">
<div class="w-100 p-3 border bg-light">Looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong text</div>
</div>
</div>
</div>
I also saw this Pen: https://codepen.io/frouo/pen/OqGaWN
Take a parent div and give a css to them
Here your html code with a parent div 'content-div'
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
<div class="container-fluid p-0">
<div class="row">
<div class="col">
<div class="content-div">
<div class="w-100 p-3 border bg-light">Looooooooooooooooooooooooooooooooooooooooooooooooong text</div>
</div>
</div>
<div class="col">
<div class="content-div">
<div class="w-100 p-3 border bg-light">Looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong text</div>
</div>
</div>
</div>
</div>
CSS
.content-div {
padding: 0 25px;
max-width: 150px;
}
Note: Try to avoid assign css to bootstrap classes
I removed the first and last padding in addition to no-gutters. This can be done, but please let me know if there is a better way to fit the Bootstrap design!
div {
overflow-wrap: break-word;
}
[class^="col-"]:first-child>div {
padding-left: 0 !important;
}
[class^="col-"]:last-child>div {
padding-right: 0 !important;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
<div class="container-fluid p-0">
<div class="row no-gutters">
<div class="col-3">
<div class="w-100 p-3 border bg-light">Looooooooooooooooooooooooooooooooooooooooooooooooong text</div>
</div>
<div class="col-3">
<div class="w-100 p-3 border bg-light">Looooooooooooooooooooooooooooooooooooooooooooooooong text2</div>
</div>
<div class="col-6">
<div class="w-100 p-3 border bg-light">Looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong text</div>
</div>
</div>
</div>

Vertical alignment in a position-fixed div

I have a div, inside a bootstrap column, that has class position-fixed so that the contents inside are fixed relative to the viewport. I am able to horizontally align these contents but I am having trouble vertically aligning it.
I know there are many methods out there in bootstrap 4, but it all seems to break due to the position-fixed class. Either the contents disappear somewhere outside the page, or nothing happens.
<div class="container-fluid">
<div class="row">
<div class="col-md">
<div class="container">
<div class="row justify-content-md-center">
<div class="position-fixed h-100 col-md-auto">
<div class="text-center vertical-center">
<h2>Title</h2>
<p>Subtext</p>
<a data-toggle="modal" data-target="#Modal" href="#">Click me</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div
If you want it to be fixed position, there's no reason to contain it inside the other elements (container, row, col) since as you said, it's positioning is relative to the viewport. Therefore, use custom CSS to center it...
.vertical-center {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
https://www.codeply.com/go/rtOA3jgjPG
Or, to use the Bootstrap classes, make the fixed element a flexbox container using d-flex, and then align-items-center to center.
<div class="position-fixed h-100 col-md-auto d-flex align-items-center">
<div>centered content</div>
<div>
https://www.codeply.com/go/TmySmKXXjC
Apply Bootstrap's flexbox utilities to the parent of the div you're trying to center (this is a good cheatsheet of what different flex properties do if you need it):
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="row">
<div class="col-md">
<div class="container">
<div class="row justify-content-md-center">
<div class="position-fixed h-100 col-md-auto d-flex align-items-center">
<div class="text-center vertical-center">
<h2>Title</h2>
<p>Subtext</p>
<a data-toggle="modal" data-target="#Modal" href="#">Click me</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Specifically, adding d-flex and align-items-center should work.
#OuterDiv {
position: fixed;
width: 100%;
height: 50px;
}
#InnerDiv {
display: inline-block;
top: 50%;
transform: translateY(-50%);
position: relative;
}

Bootstrap 4 - Full Height Drawer

I'm working on an app that uses Bootstrap 4. In addition, I'm using the material design framework. I need this app to take up the entire screen and to use the drawers that are part of the framework. I can successfully get the app to take up the entire screen by using a flexbox. However, I can't seem to get the drawer to take up all of the available height. You can see the issue in this Fiddle. The code in that Fiddle looks like this:
<div id="app" class="d-flex flex-column h-100">
<nav class="navbar sticky-top banner">
<a class="navbar-brand" href="#">My App</a>
</nav>
<div class="d-flex flex-column flex-grow">
<div class="h-100 flex-grow">
<div class="bmd-layout-container bmd-drawer-f-l bmd-drawer-overlay">
<div id="appDrawer" class="bmd-layout-drawer bg-faded">
<div class="container">
<header>Hello</header>
<p>
This is a longer block of information text.
Regardless of how long this block of text is,
the drawer should extend all the to the footer.
</p>
</div>
</div>
<main class="bmd-layout-content">
<div class="container">
<h1>
Hello
</h1>
<button class="btn btn-primary btn-raised" data-toggle="drawer" data-target="#appDrawer">Show Info</button>
</div>
</main>
</div>
</div>
<footer>
<p>Thank you for visiting!</p>
</footer>
</div>
How do I make the drawer take up the entire height between the nav and footer areas?
Thank you
One way is to make the element that wraps .bmd-layout-container a flex parent with flex-direction: column, then set the generated .bmd-layout-canvas class to flex-grow: 1.
$(document).ready(function () { $('body').bootstrapMaterialDesign(); });
body, html {
height: 100%;
}
.flex-grow {
flex: 1 0 auto;
}
.bmd-layout-canvas {
flex-grow: 1;
}
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://unpkg.com/bootstrap-material-design#4.1.1/dist/css/bootstrap-material-design.min.css" rel="stylesheet"/>
<script src="https://unpkg.com/bootstrap-material-design#4.1.1/dist/js/bootstrap-material-design.js"></script>
<div id="app" class="d-flex flex-column h-100">
<nav class="navbar sticky-top banner">
<a class="navbar-brand" href="#">My App</a>
</nav>
<div class="d-flex flex-column flex-grow">
<div class="h-100 flex-grow d-flex flex-column">
<div class="bmd-layout-container bmd-drawer-f-l bmd-drawer-overlay">
<div id="appDrawer" class="bmd-layout-drawer bg-faded">
<div class="container">
<header>Hello</header>
<p>
This is a longer block of information text.
Regardless of how long this block of text is,
the drawer should extend all the to the footer.
</p>
</div>
</div>
<main class="bmd-layout-content">
<div class="container">
<h1>
Hello
</h1>
<button class="btn btn-primary btn-raised" data-toggle="drawer" data-target="#appDrawer">Show Info</button>
</div>
</main>
</div>
</div>
<footer>
<p>Thank you for visiting!</p>
</footer>
</div>
Here's a fiddle - https://jsfiddle.net/n9c4Lbqa/
You can try setting the height in vh units. 1vh is equal to 1% of the window height (100vh = 100%). If you combine it with calc, you can set it to fill the window height minus the other elements.
.element {
height: calc(100vh - 50px);
}
Replace the 50px with whatever number is enough to clear the height / footer in your design.
Maybe not the prettiest way to do this, but works.
$(document).ready(function () { $('body').bootstrapMaterialDesign(); });
#app {
height: 100vh;
}
.flex-grow {
flex-grow: 1;
}
.fill {
height: 100%;
}
.test-wrap {
position: relative;
}
.test {
position: absolute;
top: 0px;
bottom: 0px;
left: 0px;
right: 0px;
}
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<script src="https://unpkg.com/bootstrap-material-design#4.1.1/dist/js/bootstrap-material-design.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
<link rel="stylesheet" href="https://unpkg.com/bootstrap-material-design#4.1.1/dist/css/bootstrap-material-design.min.css" />
<div id="app" class="d-flex flex-column fill">
<nav class="navbar sticky-top banner">
<a class="navbar-brand" href="#">My App</a>
</nav>
<div class="flex-grow p-r test-wrap">
<div class="h-100 flex-grow test">
<div class="bmd-layout-container bmd-drawer-f-l bmd-drawer-overlay">
<div id="appDrawer" class="bmd-layout-drawer bg-faded">
<div class="container">
<header>Hello</header>
<p>
This is a longer block of information text.
Regardless of how long this block of text is,
the drawer should extend all the to the footer.
</p>
</div>
</div>
<main class="bmd-layout-content">
<div class="container">
<h1>
Hello
</h1>
<button class="btn btn-primary btn-raised" data-toggle="drawer" data-target="#appDrawer">Show Info</button>
</div>
</main>
</div>
</div>
</div>
<footer>
<p>Thank you for visiting!</p>
</footer>
</div>
Here the flex way:
$(document).ready(function () { $('body').bootstrapMaterialDesign(); });
#app {
height: 100vh;
}
.flex-grow {
flex-grow: 1;
}
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<script src="https://unpkg.com/bootstrap-material-design#4.1.1/dist/js/bootstrap-material-design.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
<link rel="stylesheet" href="https://unpkg.com/bootstrap-material-design#4.1.1/dist/css/bootstrap-material-design.min.css" />
<div id="app" class="d-flex flex-column">
<nav class="navbar sticky-top banner">
<a class="navbar-brand" href="#">My App</a>
</nav>
<div class="flex-grow d-flex test-wrap">
<div class="flex-grow test"><!-- removed h-100 -->
<div class="bmd-layout-container bmd-drawer-f-l bmd-drawer-overlay">
<div id="appDrawer" class="bmd-layout-drawer bg-faded">
<div class="container">
<header>Hello</header>
<p>
This is a longer block of information text.
Regardless of how long this block of text is,
the drawer should extend all the to the footer.
</p>
</div>
</div>
<main class="bmd-layout-content">
<div class="container">
<h1>
Hello
</h1>
<button class="btn btn-primary btn-raised" data-toggle="drawer" data-target="#appDrawer">Show Info</button>
</div>
</main>
</div>
</div>
</div>
<footer>
<p>Thank you for visiting!</p>
</footer>
</div>
Something like this could work:
Fiddle: https://jsfiddle.net/aq9Laaew/105279/
CSS
body, html {
height: 100%;
margin: 0;
}
#app {
min-height: 100%;
}
.flex-grow {
flex: 1 0 auto;
}
.push {
height: 50px;
}
HTML
<div id="app" class="d-flex flex-column h-100">
<nav class="navbar sticky-top banner">
<a class="navbar-brand" href="#">My App</a>
</nav>
<div class="d-flex flex-column flex-grow push">
<div class="h-100 flex-grow">
<div class="bmd-layout-container bmd-drawer-f-l bmd-drawer-overlay">
<div id="appDrawer" class="bmd-layout-drawer bg-faded">
<div class="container">
<header>Hello</header>
<p>
This is a longer block of information text.
Regardless of how long this block of text is,
the drawer should extend all the to the footer.
</p>
</div>
</div>
<main class="bmd-layout-content">
<div class="container">
<h1>
Hello
</h1>
<button class="btn btn-primary btn-raised" data-toggle="drawer" data-target="#appDrawer">Show Info</button>
</div>
</main>
</div>
</div>
<footer class="flex-column h-100">
<p>Thank you for visiting!</p>
</footer>
</div>

Square responsive divs using Bootstrap 4

I want to create a grid system similar to this page using Bootstrap 4. I want to create a square box in a col-sm-4 and a longer rectangle next to it in a col-sm-8 of the same height. I'm having trouble creating a square box that is responsive. How can I do this?!
Current code:
<div class="container">
<div class="row section-box">
<div class="col-sm-4 text-center description-text">
first square box.
</div>
<div class="col-sm-8 description-image">
second rectangle box.
</div>
</div>
</div>
Things I've tried:
Using jQuery to set the height. This doesn't work with padding on the div, and isn't responsive.
This link where I managed to get a square box with a rectangle next to it, but as soon as text was added it was no longer a square.
You could use bootstrap 4 embed-responsive class and it's done
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title>Hello, world!</title>
</head>
<body>
<div class="container">
<div class="row m-5">
<div class="col-1">
<div class="embed-responsive embed-responsive-1by1 text-center">
<div class="embed-responsive-item bg-primary">col-1</div>
</div>
</div>
</div>
<div class="row m-5">
<div class="col-2">
<div class="embed-responsive embed-responsive-1by1 text-center">
<div class="embed-responsive-item bg-primary">col-2</div>
</div>
</div>
</div>
<div class="row m-5">
<div class="col-3">
<div class="embed-responsive embed-responsive-1by1 text-center">
<div class="embed-responsive-item bg-primary">col-3</div>
</div>
</div>
</div>
<div class="row m-5">
<div class="col-4">
<div class="embed-responsive embed-responsive-1by1 text-center">
<div class="embed-responsive-item bg-primary">col-4</div>
</div>
</div>
</div>
<div class="row m-5">
<div class="col-5">
<div class="embed-responsive embed-responsive-1by1 text-center">
<div class="embed-responsive-item bg-primary">col-5</div>
</div>
</div>
</div>
<div class="row m-5">
<div class="col-6">
<div class="embed-responsive embed-responsive-1by1 text-center">
<div class="embed-responsive-item bg-primary">col-6</div>
</div>
</div>
</div>
<div class="row m-5">
<div class="col-7">
<div class="embed-responsive embed-responsive-1by1 text-center">
<div class="embed-responsive-item bg-primary">col-7</div>
</div>
</div>
</div>
<div class="row m-5">
<div class="col-8">
<div class="embed-responsive embed-responsive-1by1 text-center">
<div class="embed-responsive-item bg-primary">col-8</div>
</div>
</div>
</div>
<div class="row m-5">
<div class="col-9">
<div class="embed-responsive embed-responsive-1by1 text-center">
<div class="embed-responsive-item bg-primary">col-9</div>
</div>
</div>
</div>
<div class="row m-5">
<div class="col-10">
<div class="embed-responsive embed-responsive-1by1 text-center">
<div class="embed-responsive-item bg-primary">col-10</div>
</div>
</div>
</div>
<div class="row m-5">
<div class="col-11">
<div class="embed-responsive embed-responsive-1by1 text-center">
<div class="embed-responsive-item bg-primary">col-11</div>
</div>
</div>
</div>
<div class="row m-5">
<div class="col-12">
<div class="embed-responsive embed-responsive-1by1 text-center">
<div class="embed-responsive-item bg-primary">col-12</div>
</div>
</div>
</div>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>
eventually, a pseudo element could help :
.col-sm-4:before,
.col-sm-8:before {
content: '';
width: 0;
}
.col-sm-4:before,
.col-sm-8:before,
.ib {
white-space: normal;
display: inline-block;
vertical-align: middle;
max-width: 100%;
}
.col-sm-4:before {
padding-top: 100%;
/* makes expand to a square */
}
.col-sm-8:before {
padding-top: 50%;
/* makes a rectangle half the height of a square */
}
[class^="col"] {
white-space: nowrap;
box-sizing: border-box;
box-shadow: inset 0 0 0 5px white;
padding: 0;
text-align: center;
background: url(http://lorempixel.com/400/200) tomato;
background-size: cover;
}
.row {
color: white;
text-shadow: 0 0 black, 0 0 2px black;
}
.col-sm-4 {
background: gray;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row section-box">
<div class="col-sm-4 text-center description-text p-0">
first square box.
</div>
<div class="col-sm-8 description-image p-0">
second rectangle box.
</div>
</div>
<div class="row section-box">
<div class="col-sm-8 description-image p-0">
<div class="ib">second<br> rectangle box.</div>
</div>
<div class="col-sm-4 text-center description-text p-0">
first square box.
</div>
</div>
</div>

Resources