Reputation: 12043
Is there a way to achieve this with CSS?
element height = 100% minus previous element height
Please don't provide JavaScript answers, because I already have:
CSS:
.mydiv{
height:100%;
}
JavaScript (jQuery):
$('.mydiv').each(function(){
$(this).css('height', $(this).height() - $(this).prev().height());
});
Actually, I want to reproduce the second effect of this demo using only CSS.
Thanks
Edit:
What I exactly want to achieve: I want two elements to fit vertically in their parent, without specifying the first element height
Upvotes: 0
Views: 1465
Reputation: 1349
Yes you can. But you have to have overflow:hidden on your container. Here is a link. http://jsfiddle.net/UNnGP/4/
Upvotes: 0
Reputation: 3444
You can achieve the layout without doing math using both top
and bottom
Upvotes: 1
Reputation: 11552
No, for 2 reasons:
this.height - prev.height
type of thing.Simple answer is no.
Upvotes: 0