Reputation: 19252
I have a div that I want to set the height of to 1/2 the height of another div. Is there a way I can say something like height: 50% of height of divid1;
Upvotes: 5
Views: 2758
Reputation: 4384
sorry, no, not in standard CSS. Unless you want the height of the containing DIV, then ofcourse you can use 50%. Maybe a solution for you would be to look into something like SASS (http://sass-lang.com/)
Upvotes: 1
Reputation: 1704
One method is to use Javascript:
document.getElementById('divid2').height = Math.floor(document.getElementById('divid1').height/2);
Or calculate half of the height of divid1 if the value is static.
Upvotes: 1
Reputation: 7858
With plain CSS there is no way you can do this. You'll have to use e.g. JavaScript to accomplish this.
Upvotes: 5