Hacker News new | ask | show | jobs
by bugfactory 717 days ago
I'm constantly amazed by how much can be achieved with only CSS nowadays. It seems like it's getting more powerful by the month as developers find new and tricky ways to push the boundary ;)
3 comments

Flexbox & grid took a lot of wind out of the sails of the various frameworks.

The #1 (by a long shot) reason I used to reach for things like Bootstrap was to get my divs in the right spots on the viewport. Now, I can specify sophisticated 2d layouts based upon media queries that consider a combination of viewport dimensions and other device capabilities. Not a single line of javascript is required to do this.

Yep, I had a huge library of SASS (SCSS) mixins that I’d use to accomplish a lot back in the day. ThoughtBot had (has?) a library called Bourbon that came with a bunch and they were amazing.
> I'm constantly amazed by how much can be achieved with only CSS nowadays.

Honestly it's a bit too much. CSS is used for fingerprinting and exploits. It's become a security risk to have it enabled and I think before long we'll want CSS blockers the same way we have blockers for JS. The ability to allow only sane subset of CSS would be really useful!

I've been longing for the ability to disable media queries. Just serve me the default.

It's not only useful against fingerprinting, but also when the creator's idea of what layout is appropriate on my setup differs from mine.

Modern responsive design can do away with almost 100% of media queries. I used one single media query for one element after spending several days trying to write formulas to handle a weird edge case. I dislike media queries.
Did not try it out, but an idea: write a user script that changes the <meta viewport>.

See https://developer.mozilla.org/en-US/docs/Web/HTML/Viewport_m... what this meta tag does.

You might be pretty disappointed by the defaults in many cases: it’s extremely common to start with styles for the smallest viewports (“mobile”) and use media queries to add larger viewport variants. I don’t know if you’re among the same people who complain about the overuse of mobile UI techniques on larger screens/devices, but that’s almost certainly what you’d get more of in general.
One way around it is to do what the Tor Browser does: report an arbitrary value.
That's a good point. At the same time, I believe it can make a lot of sense, particularly if it is used to implement functionality that was previously implemented in JavaScript.

Given that CSS is not an actual programming language, browser vendors can optimize it in ways that JavaScript can't. This extra optimization is a big benefit in the world of mobile devices and batteries.

Frontend devs in 2000: "Why can't we do grid layouts?!"

In 2020: "Grid is too much!" :)

Anchors in general are great, and they can be abused. Just like how we abused `transform` to vertically center things before flexbox.

>"Only CSS"

CSS is by far the most advanced, flexible, and powerful layout technology in existence.

I would maybe say that it is almost assuredly one of the most featureful and widely used layout technology. But I'm not convinced it's the most powerful, flexible, or even advanced. It suffers from significant performance issues due to legacy baggage and a poor underlying abstractions. There is a reason anyone building things like visual editors, spreadsheets, et al tend to drop into lower level rendering technologies.
I am not seeing it used much in print though.
That’s because print is an additive medium and requires support for additive colorspaces (CMYK) and device color profiles.
This is probably coming to CSS in the coming years. [0] Which makes me very excited for one reason: CSS is nearing feature parity (and surpassing it in some areas) with Adobe InDesign, so we can finally ditch adobe and just make print publications within the browser. The only other thing missing after custom colour profiles is a proper text justification algorithm, although, for many, it's not so important because people are already used to reading ragged text.

[0]: https://www.w3.org/TR/css-color-4/#color-space

It's in the CSS Color 5 spec - here: https://drafts.csswg.org/css-color-5/#cal-cmyk
I don't understand how this is still a thing in 2024.
It’s essential complexity, so it’s not going anywhere.