Reputation: 15
Set css variable equal to class property
I want to set a css variable equal to the height of one of my divs.
I tried
:root{
--height-of-div: .div1.height;
}
.div2{
height: calc(--height-of-div/2);
}
But it is not working. Please help.
Upvotes: 0
Views: 257
Reputation: 1568
Not possible using CSS alone. You could use jQuery, something like this:
function SetDivHeight() {
$("#div2").css({'height':($("#div1").height())});
}
Upvotes: 1