2

does it work in CSS to set a property by proportion to another property ? i know that i can do this with java-script, but i would be nice if this is possible with CSS.

for example : width:10 % height;

if not is there any other good way to do it. thanks for you help.

habibhassani
  • 486
  • 1
  • 6
  • 15

1 Answers1

2

Using Nenad's comment I built a fiddle https://jsfiddle.net/bv5fLrth/20/

Re-size it vertically to see the width change size.

#someDiv {
  width: calc(100vh*0.1);
  height: 200px;
  background-color: blue;
}
Adam Buchanan Smith
  • 9,422
  • 5
  • 19
  • 39