The d-flex is an inbuilt class in Bootstrap 4 which can be used to set the full height to a div. We will illustrate it with the working code example below.
Syntax:
<div class="d-flex"> ... <div>
Below code create three divs in a horizontal arrangement but the problem is the height of inner-div with class box-inner is not the same in all the divs and depends on the text in the div. We want the height to be the same for all the divs and to be equal to that of div with the longest text.
- Program:
<!DOCTYPE html><html><head><linkrel="stylesheet"href=<style>.box-inner {background: rgb(104, 201, 25);margin: 2px;}.container {margin-top: 30px;}</style></head><body><h1>GeeksforGeeks</h1><b>A Computer Science Portal for Geeks</b><divclass="container"><divclass="row"><divclass="col-12 col-lg-3 col-md-6 box"><divclass="box-inner"><pclass="content">This is my first div.</p></div></div><divclass="col-12 col-lg-3 col-md-6 box"><divclass="box-inner"><pclass="content">This is my second div with avery very long text. Text inthis div is longer than bothother divs.</p></div></div><divclass="col-12 col-lg-3 col-md-6 box"><divclass="box-inner"><pclass="content">This is my third div.</p></div></div></div></div></body></html>chevron_rightfilter_none - Output:

Solution: We will use d-flex class to increase the height of all divs and along with that we will add width: 100%; so that width of all divs is maximum of available area.
- Program:
<!DOCTYPE html><html><head><linkrel="stylesheet"href=<style>.box-inner {background: rgb(104, 201, 25);margin: 2px;width: 100%;}.container {margin-top: 30px;}</style></head><body><divclass="container"><divclass="row"><divclass="col-12 col-lg-3 col-md-6 box d-flex"><divclass="box-inner"><pclass="content">This is my first div.</p></div></div><divclass="col-12 col-lg-3 col-md-6 box d-flex"><divclass="box-inner"><pclass="content">This is my second div with a veryvery long text. Text in this divis longer than both other divs.</p></div></div><divclass="col-12 col-lg-3 col-md-6 box d-flex"><divclass="box-inner"><pclass="content">This is my third div.</p></div></div></div></div></body></html>chevron_rightfilter_none - Output:

Recommended Posts:
- How to overlay one div over another div using CSS
- How to copy the content of a div into another div using jQuery ?
- How to dynamically set the height and width of a div element using jQuery ?
- How to center a div within another div?
- How to clear all div's content inside a parent div ?
- How to set div with left image and button at bottom using bootstrap?
- How to give a div tag 100% height of the browser window using CSS
- How to place two div side-by-side of the same height using CSS?
- How to make div height expand with its content using CSS ?
- How to animate div width and height on mouse hover using jQuery ?
- How to get the <div> height using JavaScript ?
- How to dynamically get the content height of a div using AngularJS ?
- How to set the div height to auto-adjust to background size?
- How to hide div element by default and show it on click using JavaScript and Bootstrap ?
- How to place SVG icons on a round circle side by side to another div using Bootstrap?
- How to show/hide div element depending multiple values using Bootstrap and jQuery ?
- How to make a Bootstrap 4 accordion collapse when clicking the whole header div ?
- How to remove gutter space for a specific div in Bootstrap ?
- How to set one column control over height in Bootstrap ?
- HTML width/height Attribute vs CSS width/height Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


