Comments on: Breakpoint Columns, Five Ways. Which Do You Like? https://frontendmasters.com/blog/breakpoint-columns-five-ways-which-do-you-like/ Helping Your Journey to Senior Developer Thu, 18 Sep 2025 06:48:24 +0000 hourly 1 https://wordpress.org/?v=6.8.3 By: David Bushell https://frontendmasters.com/blog/breakpoint-columns-five-ways-which-do-you-like/#comment-40839 Thu, 18 Sep 2025 06:48:24 +0000 https://frontendmasters.com/blog/?p=7153#comment-40839 this is my crazy setup for equal sized columns, hear me out!

.grid {
  --column-count: 1;
  --column-gap: 30px;
  --column-gap-size: calc((var(--column-count) - 1) * var(--column-gap));
  --column-size: calc((100% - var(--column-gap-size)) / var(--column-count));
  display: grid;
  gap: var(--column-gap);
  grid-template-columns: repeat(var(--column-count), var(--column-size));
}

/* then the breakpoints like: */
@media (width >= 600px) {
  .grid {
    --column-count: 3;
  }
}

I do this because 1fr != 1fr if a column content blows out the width or whatever (never quite understood that behaviour). It also gives me custom props for the exact column size which I’ve found useful.

]]>
By: Chris Coyier https://frontendmasters.com/blog/breakpoint-columns-five-ways-which-do-you-like/#comment-40564 Mon, 15 Sep 2025 16:13:16 +0000 https://frontendmasters.com/blog/?p=7153#comment-40564 In reply to Andrew Hudson.

so cool

]]>
By: Andrew Hudson https://frontendmasters.com/blog/breakpoint-columns-five-ways-which-do-you-like/#comment-40534 Mon, 15 Sep 2025 11:14:15 +0000 https://frontendmasters.com/blog/?p=7153#comment-40534 Chris, another one to the mix. Works in latest Chrome Canary:

@function --cols(--column-count: 3, --breakpoint: 400px) {
    result: if(
        style(100vw < var(--breakpoint)): 1fr; 
        else: repeat(var(--column-count), 1fr)
    );
}

.grid {
    grid-template-columns: --cols();

        /* if you want a custom number of columns */
    grid-template-columns: --cols(5); 

    /* if you want to set the custom breakpoint */
    grid-template-columns: --cols(5, 600px); 
}

see https://codepen.io/bigandy/pen/ZYbgOzq?editors=0100

]]>
By: Chris Coyier https://frontendmasters.com/blog/breakpoint-columns-five-ways-which-do-you-like/#comment-40380 Sat, 13 Sep 2025 15:00:47 +0000 https://frontendmasters.com/blog/?p=7153#comment-40380 https://bsky.app/profile/jonathan.caprell.com/post/3lynur5w5dc2e

https://bsky.app/profile/kevinpowell.co/post/3lynvaj2cd22x

https://bsky.app/profile/css-only.dev/post/3lynvocudcs23

https://bsky.app/profile/anatudor.bsky.social/post/3lynw35jkts2b

]]>
By: Zacky Ma https://frontendmasters.com/blog/breakpoint-columns-five-ways-which-do-you-like/#comment-40345 Sat, 13 Sep 2025 07:51:31 +0000 https://frontendmasters.com/blog/?p=7153#comment-40345 Another option is style query, kinda does what we’d want custom media queries to do:

html {
  —vw-sm: true;

  @media (min-width: 37.5rem) {
    —vw-md: true;
  }

  @media (min-width: 80rem) {
    —vw-lg: true;
  }
}

.grid {
  grid-template-columns: 1fr;

  @container style(—vw-md: true) {
    grid-template-columns: repeat(3, 1fr);
  }

  @container style(—vw-lg: true) {
    grid-template-columns: repeat(5, 1fr);
  }
}
]]>
By: Markus Finell https://frontendmasters.com/blog/breakpoint-columns-five-ways-which-do-you-like/#comment-40328 Sat, 13 Sep 2025 06:07:38 +0000 https://frontendmasters.com/blog/?p=7153#comment-40328 I prefer the Switcher layout from Every Layout! 🙂

]]>
By: Jack Duvall https://frontendmasters.com/blog/breakpoint-columns-five-ways-which-do-you-like/#comment-40302 Sat, 13 Sep 2025 00:02:09 +0000 https://frontendmasters.com/blog/?p=7153#comment-40302 Those functions & if statement are crazy new features!! Very exciting but I’ll probably stick w/ (1) until browser support is there in a few years.

]]>
By: Matt Edwards https://frontendmasters.com/blog/breakpoint-columns-five-ways-which-do-you-like/#comment-40297 Fri, 12 Sep 2025 22:52:44 +0000 https://frontendmasters.com/blog/?p=7153#comment-40297 #2 with container queries.

So if you refactor and this component ends up inside a column of its own, or a different layout it responds as initially required.

]]>
By: Josh https://frontendmasters.com/blog/breakpoint-columns-five-ways-which-do-you-like/#comment-40272 Fri, 12 Sep 2025 18:21:31 +0000 https://frontendmasters.com/blog/?p=7153#comment-40272 Good piece! One nit to pick: it’s better to use rem than px in media queries.

That way, if the user cranks up the font size, the layout can adjust accordingly and stay at one column until more space is available, instead of trying to force gigantic text into three columns with only a few hundred pixels of room to work with.

]]>
By: Chris Coyier https://frontendmasters.com/blog/breakpoint-columns-five-ways-which-do-you-like/#comment-40264 Fri, 12 Sep 2025 16:07:54 +0000 https://frontendmasters.com/blog/?p=7153#comment-40264 I wrote “Advantages?” and “Disadvantages?” (with the question marks) as not all of them are objectively one or the other. You might feel differently.

]]>