I have a 3 column layout with some details below the columns.
You will notice that one of the column's height is greater than the others'. I'd like the other two divs to automatically fill the remaining space (up to the blue div). The text will be loaded dynamically so I need this to work with any column being larger (and by an arbitrary amount).
Can this be done with HTML/CSS or do I have to use some JavaScript?
HTML code (relevant part of it):
<div id="content">
<div id="iconsHolder">
<div id="info">
<div id="info_content">
<p><?php echo img('images/man.png'); ?></p>
<h2>Some guy over here</h2>
<p class="light justify">It doesn't matter what is being said at the moment. Nothing is said here.</p>
</div>
</div>
<div id="comp">
<div id="comp_content">
<p><?php echo img('images/computer.png'); ?></p>
<h2>Computer Development</h2>
<p class="light justify">Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit... Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...</p>
</div>
</div>
<div id="story">
<div id="story_content">
<p><?php echo img('images/library.png'); ?></p>
<h2>Story telling</h2>
<p class="light justify">This is another short story.</p>
</div>
</div>
</div>
<div id="details">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
</div>
CSS code (relevant part of it):
#content {
width: 60em;
margin: 0px auto;
}
#info,#comp,#story {
width: 18em;
float: left;
padding-left: 1em;
padding-right: 1em;
padding-top: 2em;
background-color: #DDD;
height: 100%;
}
#info_content,#comp_content,#story_content {
text-align: center;
}
#details {
clear: both;
background-color: #EEF;
padding: 1em;
}
The approach you made is very confusing and would make it harder to control with CSS. If you convert it to a table you'd have better results.
Then, you need to remove
float:left;
from line 8 of your CSS and insert this code at the bottom... it can be done with pure CSS using
display: table-cell
.. but there is no iE7 and below support :(Here's a solution using encompassing both methods (jQuery* and CSS), the jQuery would of course do the same thing for other browsers, but this solution means that most users would be getting a pure CSS solution with only IE7 and below needing the jQuery for "enhancement"
if you want to use the jQuery solution for all browsers then you would not need the
table-cell
ortable-row
display properties and you would need to remove the!ie7
hack from the float property - the floats would also need to be contained cross-browser so you could addoverflow: hidden
to the#iconsHolder
div - and just leavezoom: 1;
in place if you need this to work in IE6 ;)CSS:
HTML:
jQuery: (inside a conditional comment so only IE7 and below see it)
Added: JSfiddle
Note: the fiddle doesn't have the jQuery added in as I don't know how to put that in a conditional comment on the fiddle)