惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tenable Blog
K
Kaspersky official blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
The Exploit Database - CXSecurity.com
Cisco Talos Blog
Cisco Talos Blog
P
Palo Alto Networks Blog
Latest news
Latest news
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
CXSECURITY Database RSS Feed - CXSecurity.com
P
Privacy International News Feed
The Hacker News
The Hacker News
T
Tor Project blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Cisco Blogs
阮一峰的网络日志
阮一峰的网络日志
Recent Commits to openclaw:main
Recent Commits to openclaw:main
博客园_首页
N
News and Events Feed by Topic
W
WeLiveSecurity
罗磊的独立博客
GbyAI
GbyAI
T
Troy Hunt's Blog
Y
Y Combinator Blog
Recorded Future
Recorded Future
The Cloudflare Blog
TaoSecurity Blog
TaoSecurity Blog
爱范儿
爱范儿
美团技术团队
Attack and Defense Labs
Attack and Defense Labs
C
Check Point Blog
Engineering at Meta
Engineering at Meta
Cyberwarzone
Cyberwarzone
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
F
Fortinet All Blogs
The GitHub Blog
The GitHub Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Apple Machine Learning Research
Apple Machine Learning Research
Know Your Adversary
Know Your Adversary
AWS News Blog
AWS News Blog
D
DataBreaches.Net
Recent Announcements
Recent Announcements
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
M
MIT News - Artificial intelligence
Webroot Blog
Webroot Blog
Security Latest
Security Latest
T
Tailwind CSS Blog
V2EX - 技术
V2EX - 技术
aimingoo的专栏
aimingoo的专栏
S
Security @ Cisco Blogs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Mastering CSS Grid Subgrid: A Complete Guide
Nick Benksim · 2026-05-28 · via DEV Community

Nick Benksim

Mastering CSS Grid Subgrid: A Complete Guide

Grab your coffee, pull up a chair, and let's talk about one of the most satisfying CSS features to finally hit prime-time browser support: CSS Grid Subgrid.

You know the exact headache I’m talking about. You’re building a classic card layout. Each card has a thumbnail, a title, a short description, and a "Read More" button at the bottom. The designer wants all the titles to align perfectly across the row, all the descriptions to align, and all the buttons to sit exactly on the same baseline at the bottom. It looks gorgeous in Figma when every title is exactly one line. But then real-world content hits the staging server. One card has a three-line title, another has a two-word title, and suddenly your beautiful grid looks like a jagged, staggered mess.

Subgrid solves this exact, frustrating problem once and for all by letting nested elements "listen" directly to the parent grid.

How we suffered before

Before subgrid became widely supported, aligning child elements across sibling containers was an absolute nightmare. We had to resort to a laundry list of ugly workarounds that made our clean markup cry.

First, we tried hardcoding heights. We would throw a min-height or a fixed height on the card titles. This worked okay until someone resized the browser, changed the font size, or localized the site into German. Suddenly, the text would overflow, overlap, or look completely broken. If you've ever had to handle responsiveness issues related to sizing hacks, you might appreciate our guide on utilizing mathematical functions in CSS to handle sizing dynamically, but even mathematical functions couldn't save us from the inherent disconnect of isolated card containers.

Then came the JavaScript rescue mission. We would write helper scripts to calculate the height of every single title card on the row, find the tallest one, and apply that height to all of them inline. It worked, but it was bad for performance, caused layout shifts, and felt like a massive over-engineering feat for a simple layout task.

Lastly, some of us just flattened the HTML structure. We would put all the titles in one row, all the descriptions in another, and all the buttons in a third row inside the main grid. Sure, it aligned perfectly, but it completely destroyed semantic HTML, killed screen-reader accessibility, and made DOM manipulation a nightmare.

The modern way in 2026

With CSS Grid Subgrid, those hacky days are officially over. Now, a child element can opt into its parent’s grid tracks. Instead of creating an isolated grid inside each card, the card itself says: "Hey, I'm going to span three rows of the parent grid, and my children are going to align themselves directly to those rows."

To implement this, you set up your main parent grid as usual. Then, you make the card container span multiple grid rows. Finally, you apply grid-template-rows: subgrid to the card. Now, the card’s children (title, description, button) automatically inherit and snap to the exact row heights defined by the master grid across the entire row. This is the ultimate evolution of grid layouts, building beautifully on the concepts of creating complex magazine layouts with standard grids.

Ready-to-use code snippet

Here is a clean, minimal, and fully functional implementation of a card deck using CSS Grid Subgrid. Notice how the card container spans three rows, and its children automatically align perfectly across all cards, regardless of content length.

<!-- HTML Structure -->
<div class="grid-container">
  <!-- Card 1 -->
  <article class="card">
    <h3>Short Title</h3>
    <p>A quick description goes here.</p>
    <button>Read More</button>
  </article>

  <!-- Card 2 -->
  <article class="card">
    <h3>This is a Super Long Title That Spans Multiple Lines Automatically</h3>
    <p>This description has slightly more content to show off how the card content adjusts perfectly.</p>
    <button>Read More</button>
  </article>

  <!-- Card 3 -->
  <article class="card">
    <h3>Medium Title</h3>
    <p>Another short description.</p>
    <button>Read More</button>
  </article>
</div>

<style>
/* The Parent Grid */
.grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  /* Each card spans a block of 3 rows: title, paragraph, button */
  grid-template-rows: repeat(auto-fill, auto auto auto);
  gap: 30px 20px;
  padding: 20px;
  background-color: #f4f4f9;
}

/* The Grid Item (Subgrid Container) */
.card {
  display: grid;
  /* Tell the card to span exactly 3 rows of the parent grid */
  grid-row: span 3;
  /* Magic begins here: inherit row definitions from the parent grid */
  grid-template-rows: subgrid;
  
  background: #ffffff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.card h3 {
  margin: 0;
  font-family: sans-serif;
  color: #333;
}

.card p {
  margin: 0;
  font-family: sans-serif;
  color: #666;
  line-height: 1.5;
}

.card button {
  align-self: start;
  justify-self: start;
  padding: 10px 16px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
}
</style>

Common beginner mistake

The single most common mistake developers make when adopting subgrid is forgetting to define the track span on the subgrid container itself.

If you set grid-template-rows: subgrid on a card, but you don't explicitly tell that card how many tracks of the parent grid it is supposed to span (for example, using grid-row: span 3), the browser won't know how many rows to reserve for the child elements. By default, it will fall back to spanning just 1 row, causing all your internal card elements (the title, description, and button) to overlap, stack weirdly, or collapse into a single row track.

Always remember the golden rule of subgrid: the container holding the subgrid must explicitly define its track span (e.g., grid-row: span [number of children] or grid-column: span [number of columns]) so the layout engine knows exactly which parent slices to hand down to the nested elements.

🔥 We publish more advanced CSS tricks, ready-to-use snippets, and tutorials in our Telegram channel. Subscribe so you don't miss out!