Creating Equal Height Columns with CSS
Equal height columns are essential for creating visually appealing layouts. While there are various approaches, one efficient method involves using pure CSS. This tutorial demystifies the technique, dispelling the notion that it's a mere duplication of other solutions.
The Challenge
How can we create columns that:
Based on extensive research, we've discovered a unique solution.
The Answer
For a straightforward approach, embrace the following CSS trickery:
.parent { display: table; } .child { display: table-cell; }
This trick leverages table-based display properties. When the parent div assumes a table display, its child divs become table cells, inheriting equal height.
Example
<div class="parent"> <div class="child">Column 1</div> <div class="child">Column 2</div> <div class="child">Column 3</div> </div>
Note: IE7 does not play well with this approach, necessitating a more complex solution for backward compatibility.
The above is the detailed content of How to Create Equal Height Columns with Pure CSS?. For more information, please follow other related articles on the PHP Chinese website!