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.
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.
Of course there’s some downsides, but it’s refreshing to use.
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
I have no doubt there is a 'logical reason' for the behaviour but it doesn't stop it being annoying to work with.
This explains a bit more about what you’re seeing
http://stackoverflow.com/questions/28353625/why-does-percent...
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.
There is a surprisingly small amount of content out there on how to competently engineer your CSS (and a lot of it is bad). Most people don't even think it's something you do.
But basic things like making your general rules generic and pushing context descriptively into the HTML go a long way into making your code understandable.
Open instagram.com in a browser :D
A good place to learn how CSS was designed to work is Every Layout at https://every-layout.dev/.
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.
There's a well-defined algorithm (well, set of algorithms) that explain it, which you can learn if you so choose.
I will never ever do another layout without it, stuck together by glue, snot, and magical trial-and-error.
One explanation people like to give is:
CSS Grid is for layouts in 2 dimensions, Flexbox is for layouts along one dimension.
Which can be confusing because you absolutely can use Grid for layouts along one dimension too.
Here is my stupid sounding rule of thumb that I think is more useful: If you want a grid layout use grid, if you want a flexible layout use flexbox.
Grid quite literally splits the area into a grid but what if you want to just say "I want these two elements to be as far apart as possible within the container they are in" (ie a navbar, you want the logo on the left about 20 pixels away from the left of the viewpoert and you want the actual navigation to be on the right with the rightmost element 20px away from the right of the viewport). Flexbox is better for that.
(I'm considering proposing one myself).
Allowing scrolling both ways would have been perfect. Switching to left-aligned when content overflows would be acceptable. But completely prohibiting access to half the content when an overflow occurs? Absolutely asinine.
I believe there may be ways to get around this with layers of inner divs and weird `overflow: ` incantations, but that's exactly the kind of bullshit flex was supposed to solve.
See https://developer.mozilla.org/en-US/docs/Web/CSS/align-items. If you need to enable a "safe" mode to prevent data loss, and that isn't supported on any mainstream browsers... you fucked up.
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.
Flexbox complements grid imo, it's not an alternative.
It will take you from a n00b to a Grid pro in no time.
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.