I would like to calculate some value depending on other value. For example:
.my-div {
width: 50px;
height: calc(width * 2)
}
Is it possible?
I would like to calculate some value depending on other value. For example:
.my-div {
width: 50px;
height: calc(width * 2)
}
Is it possible?
See the MDN article on calc
This is an experimental feature, and would be possible- eg:
.my-div {
width: 50px;
height: calc(50px * 2);
}
However in this case as width is already known it would provide little value.
Typically in such circumstances you may be best relying on a library such as jQuery (or vanilla JS).
This is not possible in CSS, however CSS-preprocessors like SASS and LESS make it possible. Quite frankly this is one of many reasons why css-preprocessors have been developed.
I recommend you check the sites for more information.