by mkoubaa · 3y ago · 0 comments
The only exception I've encountered in my career is CSS. I'm no more effective at it than I was when I first tried using it.
There are now thousands of properties and their values, and browser engines have gone to heroic lengths to produce mostly consistent results from these often conflicting directives. But I still keep looking up basic things because the API is simultaneously sprawling and inexpressive and context-sensitive.
IMO, the core sin of CSS is mixing up three separate concerns: element styling, layout, and compositing. It’s mostly ok for the first. It’s insanely confusing for the second. And it mostly tries to pretend it’s not about the third at all, which leads to weird situations around implicit compositing groups.
We ended up here because CSS started as basically a copy of a handful of Microsoft Word dialog boxes (hence “float” etc.) And as soon as we had got the word processing use case barely working, everybody decided they wanted to build dynamic applications with this same engine instead.
Computed properties, custom properties and media queries are well designed.
It wasn't that hard, once you accept that it'll require it's own study and practice. I put in maybe 20 hours dedicated study and got a lot better out of it.
I did a few video courses on LinkedIn Learning (formerly Lynda.com) through my public library. I did a general CSS course and a flexbox CSS course. Then I set out to design pages I needed without pulling some random blog theme and calling it a day.
I've gotten a bit better at design as well, although it is a much intrinsic field than CSS and requires a lot more study. The biggest difference was once I treated the design stage with respect as its own discipline and started designing in a design tool (figma) instead of "doing it live" by trying to tweak the design in code as I went. It made me 100% focused in that stage at the design problems and the feedback loop got a lot tighter compared to editing and running code to see how it looked.
Which is why if you don't interact with it day to day basis, you'll need some trial and error, as well as references and examples.
Opposite to backend or usual programming where `foo = foo + 1` is most of the time do an increment by one (exception apply)
Combing through the CSS and the computed styles panel in dev tools gave me nothing.
It turned out there is an option to disable the standard OS form theming which isn't communicated at all in dev tools for that element (and I hadn't seen --webkit-apperance used before as the guide says you really shouldn't mess with it): https://developer.mozilla.org/en-US/docs/Web/CSS/appearance
CSS and usual programming are identical. If you don't give yourself the time to learn the fundamentals, you'll always run into tedious problems.
A good place to learn how CSS was designed to work is Every Layout at https://every-layout.dev/.
There's a well-defined algorithm (well, set of algorithms) that explain it, which you can learn if you so choose.
Sure, the box model is a prerequisite to understand CSS properly. But if you think the box model covers all aspects, you really don't know very much about CSS.
I will never ever do another layout without it, stuck together by glue, snot, and magical trial-and-error.
It will take you from a n00b to a Grid pro in no time.
Grid systems existed long before CSS grid and were dead-easy to understand and use (960, Bootstrap etc). CSS grid, by comparison, is completely unintuitive. Sure, it’s definitely more powerful, but the barrier to entry is way higher.
the framework part isn’t mandatory, but I suppose very small tweaks with something like tailwind do the trick for me.
I can’t work with css if there are massive classes and nested stuff etc. I guess composition over inheritance
Seems like there would be some sort of layer on top of it that someone built that makes things more consistent and then will compile down to the inconsistencies and odd behaviours for how CSS is supposed to be implemented.
I don't think any of those make CSS much easier, though. Quicker to use, easier to write certain things, sure. But you still need to know your way around CSS atleast somewhat before you jump in to some augmentation or replacement.
I've found that Kevin Powell [1] is a great resource for this approach, and he also helps with the model model aspect as a bonus.
I wish I could specialize on any one of these sometimes...but such is life at a startup. It's more interesting being able to do them all anyway and be able to build entire apps yourself. Just occasionally frustrating.
Last time I investigated having a uniform grid of items is impossible without falling back to custom C# layout code.