Live data from Hacker News

Full-Bleed Layout Using CSS Grid

joshwcomeau.com

1–10 of 277 posts

Re: Full-Bleed Layout Using CSS Grid

#3

This is actually a really neat technique. I've done full-bleed layouts before grid was around, but it required messing around with negative margins, which is fragile and hard to get right.

Yes, I always have to play around with some variant of

  margin: 0 calc(50vw - 50% - 1rem);
or something, which feels really hacky.

Re: Full-Bleed Layout Using CSS Grid

#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.

Re: Full-Bleed Layout Using CSS Grid

#6
Great article. While CSS grid is very powerful, maybe I'm not seeing the full picture in the examples: aren't the examples possible with just p { margin: 0 auto; max-width: 65ch } ? What does grid bring here?

Re: Full-Bleed Layout Using CSS Grid

#7
post #6

Great article. While CSS grid is very powerful, maybe I'm not seeing the full picture in the examples: aren't the examples possible with just p { margin: 0 auto; max-width: 65ch } ? What does grid bring here?

I think part of it is that there are probably lots of additional items that you want to constrain to the main column, so your CSS would end up looking more like:

    #content p, h1, h2, h3, nav { .. }
Kind of a pain to manually specify each element that you want to constrain, when it's most of them. This approach allows you to instead target the items that you don't want to constrain.

Additionally, as a more specific issue, the static-site generator that I use renders markdown such that images are inside a paragraph, so your approach wouldn't work at all for me.

Edit: As an aside, that's a super fun site! Lots of neat little UI easter eggs.

Re: Full-Bleed Layout Using CSS Grid

#8
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.

Since the element you're trying to apply the full-bleed to lives in a container that has a max-width, wouldn't you need to play with negative margins or absolute positioning to accomplish this with only margins?

Re: Full-Bleed Layout Using CSS Grid

#9
Did anyone else get weird screen flickering[0] from the animated stars used in a few places on this site? The dev-tools show the stars are elements being added/removed dynamically. The animation is cutesy, but the flickering is annoying.

FF 80.0.1 MacOS 10.14 (yeah it's old)

[0]https://vimeo.com/465078029

Re: Full-Bleed Layout Using CSS Grid

#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)
Post reply on HN