Eg setting an image to be "width: 100vw; height: 100vh;" means it'll be squished to fill the user's viewport. "width: 100vw; height: auto;" will fill the viewport horizontally and scale the image vertically as per it's aspect ratio. And so on. Generally that'll look bad though because browsers scale things fast rather than well.
And then there's the options for background images. "background-size: cover" is quite useful.
CSS is fun.
``` object-fit: cover ```
comes to mind as a client-side solution I used in the past for this problem
Generally, I'd agree that authoring time is some 9X% solution, though there remain edge cases.
I can't think of a good use case for auto generating arbitrarily large images, and as a user I wouldn't want to visit websites where the web designer thinks that's a good idea either.
What thos cases are is ... a good question, and my point is more thaat this can be done than to say why or that it's a good idea.
Upshot again is that image size need not be deterministic at authoring time.
<img width="100" height="100" style="width:100%;height:auto;" src=test.png>
and you'll get 16x16px placeholder image. In Firefox, it works. width: 2000px;
max-width: 100%;
ratio: 16/9;
Of course this gets tricky when width and height are both specified and they don't match the given ratio, but that just means that one needs to always override the other.Edit to add: Or maybe it would be better to just have the ability to lock the ratio, such as:
ratio: fixed; .DamnInteresting {
position: relative;
display: block;
}
.DamnInteresting::before {
content: '';
display: block;
/* 16:9 shim! */
padding-bottom: 56.25%;
}
.DamnInteresting img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
Ugly, but it's easy to make a mixin (or similar) if you're using a preprocessor!(The ::before element isn't stricly necessary; the padding can go on the .DamnInteresting element directly - just make sure .DamnInteresting is wrapped in a containing element of your desired width and you can even use inline styles for the padding shim.)
(Edit: a word)