0

How to make both div heights equal with css. I want to see side by side these both divs.

<div>How to make two div heights equal with css.How to make two div heights equal with css.</div>

OR

<div>How to make two div heights equal with css. How to make two div heights equal with css. How to make two div heights equal with css. How to make two div heights equal with css. How to make two div heights equal with css.</div>
Mohammed Javed
  • 866
  • 2
  • 9
  • 24

4 Answers4

3

Assuming that you have divs side by side, you can easily use:

display:flex

Your HTML is:

<div class="row">
  <div class="col">How to make two div heights equal with css.How to make two div heights equal with css.</div>

  <div class="col">How to make two div heights equal with css.How to make two div heights equal with css.How to make two div heights equal with css.How to make two div heights equal with css.How to make two div heights equal with css.</div>
</div>

The CSS will be:

.row {
    display: flex; /* equal height of the children */
}

.col{
    border: 1px solid black;
    flex:1; // use this if you want width to be equal as well

}

See the fiddle: http://jsfiddle.net/9qzzu1c7/

Nikhil Batra
  • 3,118
  • 14
  • 19
0

If I understand right you want them side by side cause divs actually appears under each other? If so:

I want to see side by side these both divs.

https://jsfiddle.net/ym2c64ay/

<div id="parent">
<div>How to make two div heights equal with css.How to make two div heights equal with css.</div>
<div>How to make two div heights equal with css. How to make two div heights equal with css. How to make two div heights equal with css. How to make two div heights equal with css. How to make two div heights equal with css.</div>
</div>

div{
    background: #F00;
    float: left;
    width: 50%;
}
0

assuming only two divs, you could use this css

div{display:inline-block;height:400px;width:48%;overflow-y:scroll;}

demo

Change the height as needed. You can set overflow to auto also.

lukeocom
  • 3,243
  • 3
  • 18
  • 30
0

there are many ways to display divs side by side, you can use floats with static widths and heights, or you can use display inline-block with percent widths and static heights.

However, none will really give you equal heights on both divs without explicitly giving a height. and its not very helpful if you have static heights because what if the text you have needs to get longer and the height can no longer hold the amount of text.

One easy way to accomplish this is to use table row and cell like this: http://jsfiddle.net/7ch85rs1/

Abdul Ahmad
  • 9,673
  • 16
  • 64
  • 127