<div class="container">
<div class="first inner">ksjdkaskdksd content</div>
<div class="middle inner">just a line of content at the bottom</div>
<div class="last inner">ksjdkaskdksd content</div>
</div>
And want the middle div to have the same height as its first siblings (class “first”). How could I arhieve this using Javascript?
EDIT: the height of the divs are dynamic, as it is a responsive site.
Hmm it looks like I wont be able to use this method on this project, even tho the trick does work. Do you know how this could be done with JS? So that the div checks the height of his siblings and applies this to itself.
=) Well, the container can have an “unlimited” number of a block with the width 25% and a dynamic height, so If you put 5-6 of these blocks in the container that would create two rows and the container would be twice as high. And then we have this odd block, who doesnt look like the rest, and only contains a background image and a small amount of text. It is this block that I want to inherit the height of it siblings (the block before or after). So wouldnt the table-cell option break if the container is filled with more blocks and more rows?
Hope you understand what i am trying to explain, my english isn’t always the best=)
The div with class “match” is the only one who differs from the others regarding height of the content, but it should still have a background-image that stretches 100% height. It’s siblings sets the height, and is dynamic. So what I want is the “match” div to inherit the same height as the other divs. But I cannot get it to work.
You can’t float an element with display: table-cell, so remove the float. Cells are also 100% the height of the container by default. It also doesn’t make sense to have 8 cells and try to set each to width: 25%. Perhaps make it a bit clearer what you are trying to achieve here.
Hmm okey i see. Well it is not up to me how many divs with the width 25% that will be in the container, could be three, could be 43, they will be added via CMS. So my solution have to work regardless of how many items there is in the container. I guess maybe one could do some JS solution that creates a new container after 4 items or something?
Do you need the divs to be visually the same height? By that I mean, will they have a background color or similar? If not, you can set them to display inline-block and give them a width that will create the right number per row. They will stay in an even row, but won’t be the same height.
Hmm yeah all other div except the one with class “match” will be visually the same, regarding looks, height and content. Then we have this “match” -div that will only have a line of text at the bottom and a background-image that have to be the same height as the other divs.