5

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;

3 Answers 3

5

With plain CSS there is no way you can do this. You'll have to use e.g. JavaScript to accomplish this.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

1

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/)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.