2

I have 3 divs with display:inline-block style. I want to set their height value so that it matches the one with the highest value. I also want to set height values auto. I've tried to show visually what I want to get below. Is this possible with pure CSS?

-----    -----    -----          -----    -----    ----- 
|   |    |   |    |   |          |   |    |   |    |   | 
-----    |   |    |   |    ==>   |   |    |   |    |   |
         -----    |   |          |   |    |   |    |   |
                  -----          -----    -----    ----- 
Joum
  • 3,189
  • 3
  • 33
  • 64
Halil Ibrahim
  • 1,339
  • 1
  • 20
  • 39
  • 1
    It's hard to understand what you want. Try rephrasing it maybe. From what I could understand you have 3 divs and you want to set their `height` for the same value of the _tallest_ of them, using just CSS, is that it? – Joum Aug 21 '13 at 13:14
  • exactly! I'm sorry about my explanation skills :) – Halil Ibrahim Aug 21 '13 at 13:17
  • 2
    You could do it if you knew which one would be the tallest... otherwise it would require the container to have a size and the inner elements to be 100%. – Sam Sussman Aug 21 '13 at 13:19
  • 2
    possible duplicate of [How do I achieve equal height divs with HTML / CSS?](http://stackoverflow.com/questions/1056212/how-do-i-achieve-equal-height-divs-with-html-css) – Naftali Aug 21 '13 at 13:22

2 Answers2

4

With CSS you can set the inner divs to be display: table-cell and the outer one to be display: table

Demo: http://jsfiddle.net/maniator/C2dNu/


HTML:

<div id='out'>
    <div class='red'></div>
    <div class='blue'></div>
    <div class='green'></div>
</div>

CSS:

.red { 
    background: red;
    height: 60px;
}
.blue { 
    background: blue;
    height: 160px; 
}
.green {
    background: green;
    height: 80px; 
}
#out {
    display: table;
    width: 500px;
}

#out > div {
    display: table-cell;
    width: 33%;
}
Naftali
  • 144,921
  • 39
  • 244
  • 303
-1

With JS, it can be done with Equalize.js. I don't know a pure CSS solution though.

Arda
  • 6,756
  • 3
  • 47
  • 67