Equalizing Heights of Floated Child DIVs
Problem:
In a page layout with a parent DIV containing two floated child DIVs, only the first child DIV expands its height to match the parent's height when content increases within it. The second child DIV remains at its default height, leaving an uneven appearance.
Solution:
To ensure the second child DIV (.child-right) expands to the same height as its parent, apply the following CSS to the parent .parent and child .child-right elements:
.parent { overflow: hidden; position: relative; width: 100%; } .child-right { background: green; height: 100%; width: 50%; position: absolute; right: 0; top: 0; }
Explanation:
By using this combination of CSS properties, the floated child DIVs will expand to match the height of their parent DIV, resulting in an equal height distribution among both children.
The above is the detailed content of How Can I Make Two Floated Child DIVs Have Equal Heights?. For more information, please follow other related articles on the PHP Chinese website!