div.post {
min-height: 40px;
}
div.a {
width: 30%;
float: left;
background-color: green;
min-height: 40px;
border: 1px solid;
}
div.b {
width: 35%;
float: left;
background-color: blue;
min-height: 40px;
border: 1px solid;
}
div.c {
width: 35%;
float: left;
background-color: yellow;
min-height: 40px;
border: 1px solid;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<title>Float Left</title>
<div class="post container">
<div class="a">Premier League: Liverpool drop points for the 1st time after 1-1 draw at Manchester UnitedPremier League: Liverpool drop points for the 1st time after 1-1 draw at Manchester UnitedPremier League: Liverpool drop points for the 1st time after 1-1 draw
at Manchester United</div>
<div class="b">at 12:00 am</div>
<div class="c">by gm</div>
<div class="a">Premier League: Liverpool drop points for the 1st time after 1-1 draw at Manchester UnitedPremier League: Liverpool drop points for the 1st time after 1-1 draw at Manchester UnitedPremier League: Liverpool drop points for the 1st time after 1-1 draw
at Manchester United</div>
<div class="b">at 12:00 am</div>
<div class="c">by gm</div>
<div class="a">Premier League: Liverpool drop points for the 1st time after 1-1 draw at Manchester UnitedPremier League: Liverpool drop points for the 1st time after 1-1 draw at Manchester UnitedPremier League: Liverpool drop points for the 1st time after 1-1 draw
at Manchester United</div>
<div class="b">at 12:00 am</div>
<div class="c">by gm</div>
<div class="a">Premier League: Liverpool drop points for the 1st time after 1-1 draw at Manchester UnitedPremier League: Liverpool drop points for the 1st time after 1-1 draw at Manchester UnitedPremier League: Liverpool drop points for the 1st time after 1-1 draw
at Manchester United</div>
<div class="b">at 12:00 am</div>
<div class="c">by gm</div>
<div class="a">Premier League: Liverpool drop points for the 1st time after 1-1 draw at Manchester UnitedPremier League: Liverpool drop points for the 1st time after 1-1 draw at Manchester UnitedPremier League: Liverpool drop points for the 1st time after 1-1 draw
at Manchester United</div>
<div class="b">at 12:00 am</div>
<div class="c">by gm</div>
</div>
I need to make 3 column with same height. How can I do this?
3
Answers
Don’t use floats for this, use flexbox instead. You can also use
display: grid;
but for your simple layout flexbox should do the job just fine.This seems like a perfect example to use CSS Grid, you can read about it here:
You could have something like this:
You should use flex or grid for the layouts instead of float left and right.
See the below working demo.