mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:48:14 +00:00

Calculate a "preferred aspect ratio" based on the value of `aspect-ratio` and the presence of a natural aspect ratio, and use that in layout. This is by no means complete or perfect, but we do now apply the given aspect-ratio to things. The spec is a bit vague, just saying to calculate sizes for aspect-ratio'ed boxes the same as you would for replaced elements. My naive solution here is to find everywhere we were checking for a ReplacedBox, and then also accept a regular Box with a preferred aspect ratio. This gets us pretty far. :^) https://www.w3.org/TR/css-sizing-4/#aspect-ratio-minimum is not at all implemented.
7 lines
171 B
HTML
7 lines
171 B
HTML
<!doctype html><style>
|
|
div, img {
|
|
width: 200px;
|
|
aspect-ratio: auto 2/1;
|
|
border: 1px solid black;
|
|
}
|
|
</style><div></div><img src="120.png"/>
|