215 points · by davidbarker · 3y ago · 155 comments
Any CSS work eventually devolves to adjusting numbers until everything falls in line, adjusting for the 2 pixels of padding there or the borders of some other thing. Maybe nowadays there is calc where you don't need to do that, but it didn't exist back when I did CSS.
IMO the browser makers are at fault for making the viewport be partially obscured under the UI.
The viewport should be just that: viewable.
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.
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.
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.
Barcelona is/was the internal name for Threads.
Copying something Meta did and playing with it just feels more interesting than an abstract example out of thin air.
Tech interview industry really misses the point sometimes
Personally I’d be hard-pressed to move an applicant with a less-than-obsessive attitude to naming forward to the next round.
When you’re an interviewer you have to make a decision based on way too little signal. This means you zoom in on the things you do see, and you accept the chance that you might reject a great candidate. I can completely imagine a company rejecting a candidate because they didn’t care about naming.
Now if you think “worried that candidate might have negative productivity due to careless attitude, soft reject” is obnoxious then fine but I think that makes you spoiled. You’re not entitled to a job, even a junior position, simply because you can write a loop or center a div. Real world engineering has more going on. Interviewers look for those signals, so better work on getting them right.
Why would you assume that impromptu interview code would be the same as production code?
With CSS grid you don't need div elements, ever.
When I've witnessed Flexbox and Grid (esp. templates) for the first time I liked Grid more, but as I've seen Flexbox more commonly used in the industry
grid-template-areas:
"avatar header"
"avatar body"
". body"
". footer";So I expect that what you are mostly seeing is the evolution of CSS, from table to flexbox to grid. Table has no real responsiveness (to screen size), Flex does it _really_ well (especially for cases where the target is both PC and Phone etc.) But it has some limitations (mostly for me around column widths and the concept of "relative" column widths.)
Grid is really nice, it's a lot more like tables in concept, but at the same time has responsive abilities. These days I'm grid-first, although there are still a few places (depending on context) where flex is more appropriate.
Of course flex is also more "well known" (because it's older.) I feel a lot more comfortable there still, and until we have sub-grids I'm also a fan of using Grid layout for the "outside" and using Flex inside specific cells.
Though while grid borrowed a lot of ideas from flex, the creative usage of the grid template is so vast that you probably need to also learn by examples.
10 years later, kind of, I got back into web dev and css and learnt about flexbox, what an incredible difference. I was so thankful I wouldn't have to deal with floats ever again
Dealing with multiple screen/windows/paper sizes, as well as dynamic resizing & scaling is incredibly hard or impossible when you've baked a fixed idea of presentation into your content, see: Latex, PDFs & old school HTML with complex tables for layout, for examples.
This ensures that if a user adjusts their browsers font size for accessibility purposes or uses dynamic type, only the text will scale. You don’t want margins/paddings to scale with font size (at least not linearly) otherwise the layout gets cramped/unusable very quickly.
As others have mentioned CSS pixels have nothing to do with hardware pixels. So there are no issues with the differences in screen densities between devices.
Hiring managers: "We don't have the time to read the blog posts of job applicants".
We get our programmers involved in that process since they are the only ones capable of knowing. Although we're a small company.