4 ms·
div { width:100px; height:100px; aspect-ratio: 3 / 2; } This is all well specified and doesn't "break" the box-model in anyway. Anytime there is
by bfgeek 5y ago
div {
width:100px; height:100px;
aspect-ratio: 3 / 2;
}
This is all well specified and doesn't "break" the box-model in anyway. Anytime there is a definite width/height specified the box well respect that width/height. The aspect-ratio is lowest on the constraint priority list if you like.
Internally in browser engines there was already an aspect-ratio for replaced elements, and these elements already had to (in a slightly different way) deal with width/height/min-width/min-height/etc. aspect-ratio was exposing and slightly generalizing what engines had already.
The example you give with allowing the width() function for margin, raises a lot of questions. E.g. you could have something like:
div {
width: auto;
margin: width(10%);
}
This gets into "difficult" territory very quickly (even more complex with calc/min/max/clamp/etc) as you'd need to try and solve a multi-variable equation. (Width depends on the size of the margins, and margins depends on the width).