Trending

#subgrid

Latest posts tagged with #subgrid on Bluesky

Latest Top
Trending

Posts tagged #subgrid

Preview
Adventures in subgrid Recently, I have solved several CSS layout problems using subgrid. I share my examples and refer to some other subgrid solutions in an article by Josh Comeau.

Adventures in subgrid I remember when I first learned about subgrid back in 2019. I created a Codepen to play around with it and was able to view it in Firefox (I think I had to enable something be...

#CSS #css #grid #subgrid

Origin | Interest | Match

0 0 0 0
Preview
Pure CSS tabs with details, grid, and subgrid ✣ S.Bistrović > It's 2025, and we can create tabs with HTML and CSS only without any hacks. I don't know about you, but this developer is happy today, even if we still need a little patience for browsers to fully support these features
0 0 0 0
Preview
Introducing CSS Grid Lanes Ooooh. This is super cool.
0 0 0 0
Video

Concave rounded shape (real transparency) on @codepen.io codepen.io/thebabydino/...

`clip-path`/ `mask` on the image don't know about the dimensions of corner elems. We need another way to create the shape taking into account how those elements are resized by text reflow. #CSS #subgrid #SVG #filter

32 4 1 1
Preview
Building a multi stage timetable with modern CSS using grid, subgrid, round(), and mod(). > The functions round() and mod() became part of the CSS Baseline in 2024, and at the time of writing they’re supported by roughly 86% of browsers according to caniuse. For older browsers I’ve added a small JavaScript fallback that calculates the session positions and applies the grid placement inline, so the timetable still works even without full CSS support. > > That’s all for this component. I hope the breakdown of the structure, the positioning logic, and the scroll-driven parts is useful if you ever need to build something similar. If you use this for your own timetable, I’d be curious to see the result.
0 0 0 0
Preview
Brand New Layouts with CSS Subgrid > Subgrid is a very versatile new tool, and it can be a bit intimidating and overwhelming, but hopefully this post has given you some ideas for the sorts of things you can start experimenting with. The good news is that you don’t have to re-architect your entire project in order to start using subgrid! The most powerful parts of subgrid are things which can be incrementally adopted.
0 0 0 0
Demo of the bug showing Firefox on the left and Edge on the right.
In Firefox both examples (grid and subgrid) are almost aligned. In Edge the subgrid version is broken and DevTools grid lines are missing

Demo of the bug showing Firefox on the left and Edge on the right. In Firefox both examples (grid and subgrid) are almost aligned. In Edge the subgrid version is broken and DevTools grid lines are missing

Just found a bug in @developer.chrome.com
subgrid doesn't work in fieldset...
github.com/webcompat/we...

What makes it worse, is that #DevTools don't display the grid lines in fieldset at all 😦

#WebCompat #subgrid #fieldset #bug

2 0 1 0

This little thing I made a little over a year ago got picked on CodePen!

Tabs with rounded corners + borders. Has keyboard navigation.

#CSS #JS #SVG #subgrid

8 1 0 0
Preview
Subgrid: how to line up elements to your heart’s content When Grid became widely available across browsers in 2017, it was an absolute game changer.

webkit.org/blog/17339/s...

oh yes - now I understand #css #subgrid better #webkit

0 0 0 0

oh yes - now I understand #css #subgrid better #webkit
webkit.org/blog/17339/subgrid-how-t...

0 0 0 0
Preview
CSS Subgrid Tutorial: A Comprehensive Guide to Advanced Grid Layouts CSS Grid is a powerful layout system that revolutionized web design, allowing developers to create complex, responsive layouts with ease. While CSS Grid provides robust tools for structuring layouts, the introduction of **subgrid** in CSS Grid Level 2 takes its capabilities to the next level. This tutorial will explain what CSS subgrid is, why it’s useful, how to implement it, and provide practical examples to help you master this feature. ## What is CSS Subgrid? CSS subgrid is a feature that allows a nested grid (a grid inside another grid) to inherit the track sizing (rows and columns) of its parent grid. This means that child elements within a nested grid can align perfectly with the parent grid’s tracks, creating consistent and harmonious layouts without the need for complex workarounds. Before subgrid, aligning nested grid items with the parent grid required manual coordination of column and row sizes, often leading to fragile or repetitive CSS. Subgrid simplifies this process by allowing nested grids to “borrow” the parent grid’s track definitions, ensuring alignment and consistency across the layout. ### Key Benefits of Subgrid * **Alignment Consistency** : Nested grid items align seamlessly with the parent grid’s tracks. * **Simplified Code** : Reduces the need for duplicate track definitions or manual sizing calculations. * **Responsive Design** : Makes it easier to maintain consistent layouts across different screen sizes. * **Flexibility** : Enables complex layouts with nested components that respect the parent grid’s structure. ## Browser Support As of June 2025, CSS subgrid is supported in all major modern browsers, including Chrome, Firefox, Edge, and Safari (since Safari 16). However, always check Can I Use for the latest browser compatibility, especially for older versions. For unsupported browsers, you can use fallbacks like regular CSS Grid or Flexbox. ## How Subgrid Works To use subgrid, you need a parent grid container and a nested grid container. The nested grid can then be set to use the `subgrid` value for its `grid-template-columns` or `grid-template-rows` (or both), allowing it to inherit the parent’s track sizing. ### Basic Syntax /* Parent grid */ .parent-grid { display: grid; grid-template-columns: 1fr 2fr 1fr; grid-template-rows: auto 1fr auto; } /* Nested grid using subgrid */ .nested-grid { display: grid; grid-template-columns: subgrid; /* Inherits parent’s column tracks */ grid-template-rows: subgrid; /* Inherits parent’s row tracks */ } The `subgrid` value tells the nested grid to use the parent grid’s column or row tracks instead of defining its own. This ensures that the nested grid’s items align with the parent grid’s structure. ## Step-by-Step Example: Building a Card Layout with Subgrid Let’s create a practical example to demonstrate subgrid: a card layout where each card contains a header, content, and footer that align with the parent grid’s columns. ### HTML Structure <div class="parent-grid"> <div class="card"> <div class="card-header">Header</div> <div class="card-content">Content</div> <div class="card-footer">Footer</div> </div> <div class="card"> <div class="card-header">Header</div> <div class="card-content">Content</div> <div class="card-footer">Footer</div> </div> </div> ### CSS with Subgrid /* Parent grid */ .parent-grid { display: grid; grid-template-columns: 1fr 2fr 1fr; gap: 20px; padding: 20px; } /* Card as a nested grid */ .card { display: grid; grid-template-columns: subgrid; /* Inherit parent’s columns */ grid-column: span 3; /* Card spans all 3 columns */ gap: 10px; background: #f9f9f9; border: 1px solid #ddd; padding: 10px; } /* Card sections */ .card-header, .card-content, .card-footer { grid-column: 1 / -1; /* Span all columns within the card */ padding: 10px; } .card-header { background: #007bff; color: white; } .card-content { background: #e9ecef; } .card-footer { background: #28a745; color: white; } ### Explanation 1. **Parent Grid** : The `.parent-grid` defines a grid with three columns (`1fr 2fr 1fr`) and a gap of 20px. 2. **Nested Grid** : Each `.card` is a nested grid that uses `grid-template-columns: subgrid` to inherit the parent’s column tracks. The `grid-column: span 3` ensures the card spans all three columns of the parent grid. 3. **Card Sections** : The `.card-header`, `.card-content`, and `.card-footer` span all columns within the card’s subgrid using `grid-column: 1 / -1`. 4. **Styling** : Basic styling is applied to differentiate the card sections visually. This setup ensures that the card’s internal elements align with the parent grid’s columns, creating a clean and consistent layout. ## Advanced Use Case: Nested Form Layout Subgrid is particularly useful for aligning form elements across multiple sections. Let’s create a form with labeled inputs that align perfectly using subgrid. ### HTML Structure <div class="form-grid"> <div class="form-section"> <label>Name</label> <input type="text" placeholder="Enter name"> <label>Email</label> <input type="email" placeholder="Enter email"> </div> <div class="form-section"> <label>Address</label> <input type="text" placeholder="Enter address"> <label>Phone</label> <input type="tel" placeholder="Enter phone"> </div> </div> ### CSS with Subgrid /* Parent grid */ .form-grid { display: grid; grid-template-columns: minmax(100px, 1fr) 2fr; gap: 15px; padding: 20px; max-width: 600px; margin: 0 auto; } /* Form section as a nested grid */ .form-section { display: grid; grid-template-columns: subgrid; /* Inherit parent’s columns */ grid-column: 1 / -1; /* Span all columns */ gap: 10px; } /* Form elements */ label { grid-column: 1; /* First column for labels */ font-weight: bold; } input { grid-column: 2; /* Second column for inputs */ padding: 8px; border: 1px solid #ccc; border-radius: 4px; } ### Explanation 1. **Parent Grid** : The `.form-grid` defines a two-column layout: a label column (`minmax(100px, 1fr)`) and an input column (`2fr`). 2. **Nested Grid** : Each `.form-section` uses `grid-template-columns: subgrid` to inherit the parent’s column tracks. It spans both columns with `grid-column: 1 / -1`. 3. **Form Elements** : Labels are placed in the first column (`grid-column: 1`), and inputs in the second (`grid-column: 2`), ensuring perfect alignment across sections. 4. **Responsive Design** : The `minmax` function ensures the label column doesn’t shrink below 100px, maintaining readability. This layout ensures that all labels and inputs align consistently, even across different form sections. ## Tips for Using Subgrid Effectively 1. **Use Subgrid Sparingly** : Subgrid is powerful but not always necessary. For simple layouts, regular CSS Grid or Flexbox may suffice. 2. **Combine with Other Grid Features** : Use subgrid alongside `auto-fit`, `minmax`, or named grid lines for more dynamic layouts. 3. **Fallbacks for Older Browsers** : Use feature queries (`@supports`) to provide fallbacks: @supports not (grid-template-columns: subgrid) { .nested-grid { grid-template-columns: 1fr 2fr 1fr; /* Fallback */ } } 1. **Test Responsiveness** : Ensure subgrid layouts adapt well to different screen sizes using media queries or responsive units like `fr` and `vw`. 2. **Debugging** : Use browser DevTools to inspect the grid lines and ensure subgrid tracks align as expected. ## Common Pitfalls and Solutions * **Pitfall** : Subgrid doesn’t work if the parent isn’t a grid container. * **Solution** : Ensure the parent element has `display: grid`. * **Pitfall** : Nested grid items don’t align if `grid-column` or `grid-row` spans are incorrect. * **Solution** : Double-check span values and ensure the nested grid spans the intended tracks. * **Pitfall** : Subgrid ignores parent’s `gap` property. * **Solution** : Explicitly set `gap` on the nested grid if needed. ## Conclusion CSS subgrid is a game-changer for creating complex, aligned layouts with minimal effort. By allowing nested grids to inherit their parent’s track sizing, subgrid eliminates the need for manual coordination and ensures consistency across your design. Whether you’re building card layouts, forms, or intricate dashboards, subgrid empowers you to create robust, responsive layouts that are both maintainable and visually appealing. To deepen your understanding, experiment with the examples provided, combine subgrid with other CSS Grid features, and explore real-world use cases. With practice, subgrid will become an indispensable tool in your web design toolkit. For further learning, check out the MDN Web Docs on Subgrid and try building your own layouts to see subgrid in action.
0 0 0 0
Preview
CSS Subgrid Tutorial: A Comprehensive Guide to Advanced Grid Layouts CSS Grid is a powerful layout system that revolutionized web design, allowing developers to create complex, responsive layouts with ease. While CSS Grid provides robust tools for structuring layouts, the introduction of **subgrid** in CSS Grid Level 2 takes its capabilities to the next level. This tutorial will explain what CSS subgrid is, why it’s useful, how to implement it, and provide practical examples to help you master this feature. ## What is CSS Subgrid? CSS subgrid is a feature that allows a nested grid (a grid inside another grid) to inherit the track sizing (rows and columns) of its parent grid. This means that child elements within a nested grid can align perfectly with the parent grid’s tracks, creating consistent and harmonious layouts without the need for complex workarounds. Before subgrid, aligning nested grid items with the parent grid required manual coordination of column and row sizes, often leading to fragile or repetitive CSS. Subgrid simplifies this process by allowing nested grids to “borrow” the parent grid’s track definitions, ensuring alignment and consistency across the layout. ### Key Benefits of Subgrid * **Alignment Consistency** : Nested grid items align seamlessly with the parent grid’s tracks. * **Simplified Code** : Reduces the need for duplicate track definitions or manual sizing calculations. * **Responsive Design** : Makes it easier to maintain consistent layouts across different screen sizes. * **Flexibility** : Enables complex layouts with nested components that respect the parent grid’s structure. ## Browser Support As of June 2025, CSS subgrid is supported in all major modern browsers, including Chrome, Firefox, Edge, and Safari (since Safari 16). However, always check Can I Use for the latest browser compatibility, especially for older versions. For unsupported browsers, you can use fallbacks like regular CSS Grid or Flexbox. ## How Subgrid Works To use subgrid, you need a parent grid container and a nested grid container. The nested grid can then be set to use the `subgrid` value for its `grid-template-columns` or `grid-template-rows` (or both), allowing it to inherit the parent’s track sizing. ### Basic Syntax /* Parent grid */ .parent-grid { display: grid; grid-template-columns: 1fr 2fr 1fr; grid-template-rows: auto 1fr auto; } /* Nested grid using subgrid */ .nested-grid { display: grid; grid-template-columns: subgrid; /* Inherits parent’s column tracks */ grid-template-rows: subgrid; /* Inherits parent’s row tracks */ } The `subgrid` value tells the nested grid to use the parent grid’s column or row tracks instead of defining its own. This ensures that the nested grid’s items align with the parent grid’s structure. ## Step-by-Step Example: Building a Card Layout with Subgrid Let’s create a practical example to demonstrate subgrid: a card layout where each card contains a header, content, and footer that align with the parent grid’s columns. ### HTML Structure <div class="parent-grid"> <div class="card"> <div class="card-header">Header</div> <div class="card-content">Content</div> <div class="card-footer">Footer</div> </div> <div class="card"> <div class="card-header">Header</div> <div class="card-content">Content</div> <div class="card-footer">Footer</div> </div> </div> ### CSS with Subgrid /* Parent grid */ .parent-grid { display: grid; grid-template-columns: 1fr 2fr 1fr; gap: 20px; padding: 20px; } /* Card as a nested grid */ .card { display: grid; grid-template-columns: subgrid; /* Inherit parent’s columns */ grid-column: span 3; /* Card spans all 3 columns */ gap: 10px; background: #f9f9f9; border: 1px solid #ddd; padding: 10px; } /* Card sections */ .card-header, .card-content, .card-footer { grid-column: 1 / -1; /* Span all columns within the card */ padding: 10px; } .card-header { background: #007bff; color: white; } .card-content { background: #e9ecef; } .card-footer { background: #28a745; color: white; } ### Explanation 1. **Parent Grid** : The `.parent-grid` defines a grid with three columns (`1fr 2fr 1fr`) and a gap of 20px. 2. **Nested Grid** : Each `.card` is a nested grid that uses `grid-template-columns: subgrid` to inherit the parent’s column tracks. The `grid-column: span 3` ensures the card spans all three columns of the parent grid. 3. **Card Sections** : The `.card-header`, `.card-content`, and `.card-footer` span all columns within the card’s subgrid using `grid-column: 1 / -1`. 4. **Styling** : Basic styling is applied to differentiate the card sections visually. This setup ensures that the card’s internal elements align with the parent grid’s columns, creating a clean and consistent layout. ## Advanced Use Case: Nested Form Layout Subgrid is particularly useful for aligning form elements across multiple sections. Let’s create a form with labeled inputs that align perfectly using subgrid. ### HTML Structure <div class="form-grid"> <div class="form-section"> <label>Name</label> <input type="text" placeholder="Enter name"> <label>Email</label> <input type="email" placeholder="Enter email"> </div> <div class="form-section"> <label>Address</label> <input type="text" placeholder="Enter address"> <label>Phone</label> <input type="tel" placeholder="Enter phone"> </div> </div> ### CSS with Subgrid /* Parent grid */ .form-grid { display: grid; grid-template-columns: minmax(100px, 1fr) 2fr; gap: 15px; padding: 20px; max-width: 600px; margin: 0 auto; } /* Form section as a nested grid */ .form-section { display: grid; grid-template-columns: subgrid; /* Inherit parent’s columns */ grid-column: 1 / -1; /* Span all columns */ gap: 10px; } /* Form elements */ label { grid-column: 1; /* First column for labels */ font-weight: bold; } input { grid-column: 2; /* Second column for inputs */ padding: 8px; border: 1px solid #ccc; border-radius: 4px; } ### Explanation 1. **Parent Grid** : The `.form-grid` defines a two-column layout: a label column (`minmax(100px, 1fr)`) and an input column (`2fr`). 2. **Nested Grid** : Each `.form-section` uses `grid-template-columns: subgrid` to inherit the parent’s column tracks. It spans both columns with `grid-column: 1 / -1`. 3. **Form Elements** : Labels are placed in the first column (`grid-column: 1`), and inputs in the second (`grid-column: 2`), ensuring perfect alignment across sections. 4. **Responsive Design** : The `minmax` function ensures the label column doesn’t shrink below 100px, maintaining readability. This layout ensures that all labels and inputs align consistently, even across different form sections. ## Tips for Using Subgrid Effectively 1. **Use Subgrid Sparingly** : Subgrid is powerful but not always necessary. For simple layouts, regular CSS Grid or Flexbox may suffice. 2. **Combine with Other Grid Features** : Use subgrid alongside `auto-fit`, `minmax`, or named grid lines for more dynamic layouts. 3. **Fallbacks for Older Browsers** : Use feature queries (`@supports`) to provide fallbacks: @supports not (grid-template-columns: subgrid) { .nested-grid { grid-template-columns: 1fr 2fr 1fr; /* Fallback */ } } 1. **Test Responsiveness** : Ensure subgrid layouts adapt well to different screen sizes using media queries or responsive units like `fr` and `vw`. 2. **Debugging** : Use browser DevTools to inspect the grid lines and ensure subgrid tracks align as expected. ## Common Pitfalls and Solutions * **Pitfall** : Subgrid doesn’t work if the parent isn’t a grid container. * **Solution** : Ensure the parent element has `display: grid`. * **Pitfall** : Nested grid items don’t align if `grid-column` or `grid-row` spans are incorrect. * **Solution** : Double-check span values and ensure the nested grid spans the intended tracks. * **Pitfall** : Subgrid ignores parent’s `gap` property. * **Solution** : Explicitly set `gap` on the nested grid if needed. ## Conclusion CSS subgrid is a game-changer for creating complex, aligned layouts with minimal effort. By allowing nested grids to inherit their parent’s track sizing, subgrid eliminates the need for manual coordination and ensures consistency across your design. Whether you’re building card layouts, forms, or intricate dashboards, subgrid empowers you to create robust, responsive layouts that are both maintainable and visually appealing. To deepen your understanding, experiment with the examples provided, combine subgrid with other CSS Grid features, and explore real-world use cases. With practice, subgrid will become an indispensable tool in your web design toolkit. For further learning, check out the MDN Web Docs on Subgrid and try building your own layouts to see subgrid in action.
0 0 0 0
Screenshot of one of the possible layouts, the one for the wide screen case in particular.

Screenshot of one of the possible layouts, the one for the wide screen case in particular.

Irregular shaped image with both convex & concave roundings. Shape depends on other elements, how they scale/ wrap. Flexible layout depending on viewport.

Because someone asked how to
www.reddit.com/r/css/commen...

Live on @codepen.io codepen.io/thebabydino/...

#CSS #subgrid + #SVG #filter magic.

29 5 0 0
Screenshot of the demo, with DevTools open, highlighting the grid areas and gaps.

Screenshot of the demo, with DevTools open, highlighting the grid areas and gaps.

A super simple little #CSS #subgrid example on @codepen.io:

codepen.io/thebabydino/...

9 2 0 0
Screenshot of zaneops, showing subgrid usage on a component

Screenshot of zaneops, showing subgrid usage on a component

I am using #subgrid on my app, pretty cool when you get the use case for it.

1 0 0 0
Tabs with rounded corners and border.

Tabs with rounded corners and border.

If you also want borders, I made another (hopefully accessible) tabs pattern demo using #SVG #filter and #CSS #subgrid to answer another reddit question last year www.reddit.com/r/css/commen...

No extra elements or pseudos to create corner roundings. Works with unknown tab content length.

11 0 0 0
Preview
CSSのsubgrid(サブグリッド)の使い方 | Free Style HTMLとCSSでコンテンツの横並びを実装するCSS Gridでは、subgrid(サブグリッド)を使うことで手軽に横並びレイアウトの要素の中の高さを揃えることができます。ここではCSSのsubgridの使い方を、カード型レイアウトを例にご紹介します。

CSSのsubgrid(サブグリッド)の使い方
blanche-toile.com/web/css-subg...

#Design #WebDesign #CSS #subgrid #デザイン #Webデザイン #サブグリッド

1 0 0 0
Preview
CSSのsubgrid(サブグリッド)の使い方 | Free Style HTMLとCSSでコンテンツの横並びを実装するCSS Gridでは、subgrid(サブグリッド)を使うことで手軽に横並びレイアウトの要素の中の高さを揃えることができます。ここではCSSのsubgridの使い方を、カード型レイアウトを例にご紹介します。

CSSのsubgrid(サブグリッド)の使い方

blanche-toile.com/web/css-subg...

#Design #WebDesign #CSS #subgrid

0 0 0 0
Preview
CSSのsubgrid(サブグリッド)の使い方 | Free Style HTMLとCSSでコンテンツの横並びを実装するCSS Gridでは、subgrid(サブグリッド)を使うことで手軽に横並びレイアウトの要素の中の高さを揃えることができます。ここではCSSのsubgridの使い方を、カード型レイアウトを例にご紹介します。

CSSのsubgrid(サブグリッド)の使い方

blanche-toile.com/web/css-subg...

#Design #WebDesign #CSS #GridLayout #subgrid #デザイン #Webデザイン #グリッドレイアウト #サブグリッド

1 0 0 0
Preview
CSSのsubgrid(サブグリッド)の使い方 | Free Style HTMLとCSSでコンテンツの横並びを実装するCSS Gridでは、subgrid(サブグリッド)を使うことで手軽に横並びレイアウトの要素の中の高さを揃えることができます。ここではCSSのsubgridの使い方を、カード型レイアウトを例にご紹介します。

CSSのsubgrid(サブグリッド)の使い方

https://blanche-toile.com/web/css-subgrid
via @akirao.bsky.social

#Design #WebDesign #CSS #GridLayout #subgrid #デザイン #Webデザイン #グリッドレイアウト #サブグリッド

0 0 0 0
Blue text on orange background:
Using CSS subgrid to design advanced layouts

Blue text on orange background: Using CSS subgrid to design advanced layouts

🔵🟠 Using CSS subgrid to design advanced layouts
by Ibadehin Mojeed @ibaslogic at @LogRocket
#css #subgrid #webdev

blog.logrocket.com/using-css-su...

0 0 0 0