Live data from Hacker News

Full-Bleed Layout Using CSS Grid

joshwcomeau.com

31–40 of 277 posts

Re: Full-Bleed Layout Using CSS Grid

#32

Earlier quoted context omitted.

CSS is declarative and not imperative. A lot of people have issues with a different kind of programming. Also the "cascading" nature of CSS makes it hard to reason about.

The differences in how different engines/platforms behave definitely does not help when doing any non-trivial layout.

I think a _lot_ of this is standardised now in the vast majority of browsers people use.

Re: Full-Bleed Layout Using CSS Grid

#33
post #13

It’s beyond me why CSS has to be so hard to understand. I have made several attempts and got it right, but it feels like I have to start at zero every time. I believe, it’s because CSS is not a programming language, but we are trying to do programming with it. Like: if screen is mobile then render divs stacked. I don’t know

I think CSS is "difficult to understand" because most people who do front-end don't want to spend a day learning it. Ask some people who make the claim it's difficult: what is the box model, and what is selector specificity. I can almost guarantee they won't be able to answer those questions, because they haven't bothered to actually try to learn CSS. Their knowledge of CSS is built from a set of "how do I do X in CS…

You could probably write an article that'd be very often read if you teach CSS from this perspective.

Re: Full-Bleed Layout Using CSS Grid

#36
post #33

Earlier quoted context omitted.

I think CSS is "difficult to understand" because most people who do front-end don't want to spend a day learning it. Ask some people who make the claim it's difficult: what is the box model, and what is selector specificity. I can almost guarantee they won't be able to answer those questions, because they haven't bothered to actually try to learn CSS. Their knowledge of CSS is built from a set of "how do I do X in CS…

You could probably write an article that'd be very often read if you teach CSS from this perspective.

I've wanted to actually! It's become almost a meme that CSS is hard and a badge of honor to be ignorant of it, but it's not that bad. I will concede that there are some annoying design decisions (like margin collapsing) but overall, I think it's a well-designed and evolving solution that has stood the test of time. That we've been able to so easily add things like flexbox and Grid to it in response to the changing needs of the web is kind of a testament of how well CSS modelled the problem of layout. Learning box-model and cascading will let one solve 90% of common CSS problems people encounter just from first principles.

Re: Full-Bleed Layout Using CSS Grid

#37
post #4

Wait until Web developers find about setting a width and horizontal margins: auto on a block container again. As a matter of fact, that would require even less attributes to work compared to the method presented in the article.

Doesn't that just make it tricky to put stuff in the sidebars again? The article doesn't really talk about that but it is implied.

Re: Full-Bleed Layout Using CSS Grid

#38
Just wanted to say that's an excellent tutorial. I almost never touch anything on the front end. My web dev skills are, at best, thoroughly out of date. But I could still follow and understand everything presented. If you're reading, thanks Josh. Great job.

Re: Full-Bleed Layout Using CSS Grid

#39
post #10

> It's relatively easy to constrain all children, but CSS doesn't really have a mechanism to selectively constrain some children. Yes it does. You can use .wrapper h1, .wrapper p {} or soon .wrapper :is(h1,p) {} Alternatively, you can also use .wrapper > :not(.full-bleed) {} And in SCSS (or similar) you can write .wrapper { h1,p {} } (edit: Earlier versions of this comment mentioned :has instead of :is)

:has is not supported in any browser, and that seems unlikely to change, for performance reasons. https://caniuse.com/css-has

You can support :has(), and things like it yourself via client-side JavaScript styling runtimes well enough.
Post reply on HN