Make div's height 100% of parent element with other div children with float

Mike Feng

I'm trying to create a row of children elements with equal height. However, the children elements contain images of variable height, so the height should be that of the tallest element. Imagine the following:

<div class="parent">
    <div class="child"><img /></div>
    <div class="child"><img /></div>
    <div class="child"><img /></div>
    <div class="child"><img /></div>
</div>

This is the CSS:

.child {float:left;width:25%}

Visual description .

I understand this can be done with javascript. However that's out of the question for me (at least I think so) because this is part of an overall responsive design, so the width of the children, while set at 25%, will change with different screen sizes to, say, 50%.

Thanks in advanced!

Dylan Watt

In in the traditional document flow, parents either size their children or are sized by them, they can't normally do both.

That is without flexbox. If you deal with the modern browser requirement, it's the solution you need. http://osvaldas.info/flexbox-based-responsive-equal-height-blocks-with-javascript-fallback is a good example of how to do these type sizings.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to make div have 100% height of parent, independent of children's size? Complex layout

Make children span/div take 100% width and auto height for parent div

How to make div height to 100% of parent td

Make div height equal to its parent (100%)

Parent div takes height of first child element and not the sum of all children's height

while setting the span element height as 100% it is not set as parent Div height

CSS - Expand float child DIV height to parent's height

Set a div element's height dependent on other div element

Parent div's height is larger than his children

input element with css height: 100% overflow parent div

How to force child div to be 100% of parent div's height without specifying parent's height?

How to make a floated div 100% height of its parent?

Make Div Element 100% Height of Browser Window Using CSS

scale a div after children or 100% of window height

Child div's height not stretching to 100% of parent div's auto height

Parent div, with two children, on of them with exact height, how to give the other child "free left" space as height

Make all children of div to take up 100% height and 100% width so that only the first is visible

100% height div wrapper expand with 100% height children

Make floating div 100% height of parent that uses min-height, while still allowing parent to expand

Keeping parent div to width and height of wrapping children

Expanding a parent <div> to the height of its children

CodeMirror fill Div and make Div 100% height

Make span height 100% of outer div height

How can I make a div element float left after another float left while still filling the rest of the parent's width?

Make div height adjustable to parent div based on previous div height

Make multiple embedded div's height the same with their parent div's height

Div float keep fixed and 100% height of the viewport

Div parent and two children, get id of one children in other children

Make span heights equal to its parent div's height