Basically: be there or be square (fill up the space or not, your choice), but if you show up there’s a dress code (you can only fill up the space as specified).
> Oh look, lets define a new property and call it aspect ratio, and then lets ensure it doesn't maintain an element's aspect ratio if you have content that is going to overflow if you specify a width. This is what drives me mad about css, it's gotchas all the way down.
There’s a lot I don’t like about CSS, but this is just the spec avoiding undefined behavior. No one is using aspect ratio for unbounded text in practice, they’re using it for media or a design system. Knowing how it behaves for edge cases is much better than having a protracted battle for years while vendors sort it out, with different assumptions in the wild.
- overflow is assumed by default and constraining it is a whole bunch of necessary compromises, so my element maintains an aspect ratio but its content is overlapping siblings with the same aspect ratio. What the hell were they thinking?
- my element with 16:9 aspect ratio and the full text content of Moby Dick serialized as JSON was so wide my browser ate all my memory and swap, locked my computer up forcing a hard reboot
Reminds me of when YouTube added a new comment system, but didn't specify a max length, and rendered the full text by default. People were spamming the Bible in comments.
If you want to maintain the aspect-ratio, just remove the explicit width. Then the box will be extremely wide and tall and will move to its own line. Probably not what the developer wants to achieve.
You could say that the default behaviour should be to clip the content, like overflow: hidden does. But in CSS, the content always has priority. And it will be (overflow:) visible by default. But as a user you can still choose to clip it (overflow: hidden), or make it scroll (overflow: scroll).
CSS has all the tools for you to choose the behaviour you want. And I think this aspect-ratio property is going to save me a lot of trouble.
I may not have this exactly right, but i have an intuition that width and height are treated differently by CSS, and the aspect-ratio example is a consequence of some other fundamental rule/principle, not something unique to aspect-ratio.
Maybe someone else can explain this more specifically.
And don't forget, every time a new half-baked shitty piece of the spec is added to poorly address something people have been complaining about for 15 years, tons of people will write articles (and these days go on Twitter) gushing over how amazing CSS is for granting these gifts from the gods.
Front-end really doesn't need to be as difficult to do day-to-day as back-end (concern balancing, i.e. perf vs storage vs cost vs fault tolerance vs maintainability vs monitoring vs etc, is the extremely difficult fundamental problem you always face in back-end/SRE/DevOps, but that's all mostly trivial in front-end, which is why being a React guru isn't anywhere near as rare as being able to scale a legacy PHP app to 1M DAU), it just has a lot of pointless complexity because these technologies are designed like absolute ass, and only inch forward by committee.
Your rant about back-end/SRE/DevOps being inherently more difficult comes off as ill-informed. Where do you get the idea that balancing performance, cost, maintainability and monitoring are trivial on the front-end?
„my static blog and I cant get the text centered, damn css!“
instead of
„basically a full blown native application but written using browser APIs, with live collaboration features, GPU-using code where performance matters, oh and did i mention it must also work and look good on a mobile screen?“
I don't think I'm ill-informed, I've spent at least 5 years in each of front-end, back-end, and SRE/devops...I won't deny that there are some things that are really difficult on front-end (and in fact I don't like doing it because I don't find the challenges it offers very rewarding, though they take a lot of time), but in my experience, back-end is much, much harder at scale.
But the big distinction is that whereas frontend design/architecture/concerns are roughly the same no matter how many users you have, difficulty of back-end scales (about logarithmically) with traffic - 1k DAU is trivial, 100k is easy, 1M is "interesting", 10M is starting to get hard, 100M+ and you need to be top of your damn game (with a team to match) or you fail hard. Most projects don't have to ever reach the difficult regions, but to be perfectly honest my (non-side-project) backend work has all been in the large scale regime, so maybe for the average project across the industry the relative difficulty is about the same.
If you're in "git push heroku main" territory, then sure, frontend is probably a lot harder than backend.
To the first point, that's all fine and good, I think you're actually correct, I'm just tired of the fanboy-ism around CSS, and maybe I'm bitter because of how obnoxious the fanboys we're back when it was truly unusable. 10+ years ago there were people arguing vehemently that things like flexbox were completely pointless and in fact DANGEROUS because CSS was already perfect and could do anything as long as you weren't a noob, which was just ridiculous and wrong. I'll accept that things have gotten a lot better now and the stakes really are much higher w.r.t. changes.
Why? Why would you have different default behaviours if you have one of the dimensions set but not the other? Why would you not have this specified in another property, the overflow property perhaps? Oh look, lets define a new property and call it aspect ratio, and then lets ensure it doesn't maintain an element's aspect ratio if you have content that is going to overflow if you specify a width. This is what drives me mad about css, it's gotchas all the way down.