The problem you are talking about is called "faux columns", which has been said and described well over the past few years :) http://www.alistapart.com/articles/fauxcolumns/
There are several solutions:
- use the background in the containing div, which will simulate the border
- use CSS3 methods (display: table and display: table-cell, but they are not really designed for this or CSS3 flexbox, which is very experimental and probably won't work in most browsers)
- use JS to set the column height to the maximum element height
The latter solution is not bad, so if you use jQuery, then this can be achieved as follows:
var max=0; $('#container').children().each(function(){ if($(this).height()>max) max = $(this).height(); }); $('#container').children().each(function(){ $(this).height(max); });
The script iterates through all the children of the container and finds the highest element. Then it repeats and sets the maximum height for each of them.
source share