Claude Code के साथ CSS Grid
Claude Code का उपयोग करके CSS Grid सीखें। Practical tips और code examples शामिल हैं।
CSS Grid से Complex Layouts को आसानी से Implement करें
CSS Grid modern layout design का core है। Claude Code का उपयोग करके, complex grid layout code कम समय में accurately generate किया जा सकता है।
Basic Grid Layout
> CSS Grid से dashboard layout बनाओ।
> Header, sidebar, main content, footer — चार areas में।
/* Dashboard layout */
.dashboard {
display: grid;
grid-template-columns: 250px 1fr;
grid-template-rows: 60px 1fr 40px;
grid-template-areas:
"header header"
"sidebar main"
"sidebar footer";
min-height: 100vh;
}
.header { grid-area: header; }
.sidebar { grid-area: sidebar; }
.main { grid-area: main; }
.footer { grid-area: footer; }
/* Responsive: mobile पर 1 column */
@media (width < 768px) {
.dashboard {
grid-template-columns: 1fr;
grid-template-rows: 60px auto 1fr 40px;
grid-template-areas:
"header"
"sidebar"
"main"
"footer";
}
}
auto-fill / auto-fit से Automatic Layout
/* Card grid: automatically column count adjust */
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: 1.5rem;
}
/* auto-fit: items कम होने पर stretch */
.stretch-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 1rem;
}
/* Comparison point:
auto-fill → empty tracks maintain करता है (item width fixed)
auto-fit → empty tracks collapse करता है (items stretch होते हैं) */
Magazine Layout
/* Magazine-style irregular grid */
.magazine {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-auto-rows: 200px;
gap: 1rem;
}
.magazine .featured {
grid-column: span 2;
grid-row: span 2;
}
.magazine .wide {
grid-column: span 2;
}
.magazine .tall {
grid-row: span 2;
}
Subgrid का उपयोग
/* Subgrid से card के अंदर elements align करें */
.card-list {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
gap: 1.5rem;
}
.card {
display: grid;
grid-template-rows: subgrid;
grid-row: span 3; /* Title, body, footer — 3 rows */
}
.card__title {
align-self: start;
font-size: 1.25rem;
font-weight: bold;
}
.card__body {
align-self: start;
}
.card__footer {
align-self: end;
border-top: 1px solid #eee;
padding-top: 0.5rem;
}
Named Lines से Advanced Layout
.page {
display: grid;
grid-template-columns:
[full-start] minmax(1rem, 1fr)
[content-start] min(65ch, 100%)
[content-end] minmax(1rem, 1fr)
[full-end];
}
.page > * {
grid-column: content;
}
.page .full-bleed {
grid-column: full;
}
.page .wide {
grid-column: full;
max-width: 90rem;
margin-inline: auto;
padding-inline: 1rem;
}
CSS Grid Animation
/* Grid transition animation */
.animated-grid {
display: grid;
grid-template-columns: 1fr 1fr;
transition: grid-template-columns 0.3s ease;
}
.animated-grid.collapsed {
grid-template-columns: 0fr 1fr;
}
.animated-grid .sidebar {
overflow: hidden;
min-width: 0;
}
Practical Utility Classes
/* Grid utilities */
.grid-1 { grid-template-columns: 1fr; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }
.gap-lg { gap: 1.5rem; }
.gap-xl { gap: 2rem; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-full { grid-column: 1 / -1; }
Summary
CSS Grid को Flexbox के साथ अलग-अलग use करके, हर तरह के layout handle किए जा सकते हैं। Claude Code का उपयोग करके, subgrid और named lines जैसी advanced features भी accurately implement की जा सकती हैं। Media query के साथ combine करके responsive support भी ज़रूर करें। CSS Grid की detailed specification के लिए CSS Grid Layout Module Level 2 देखें।
मुफ़्त PDF: 5 मिनट में Claude Code चीटशीट
बस अपना ईमेल दर्ज करें और हम तुरंत A4 एक-पृष्ठ चीटशीट PDF भेज देंगे।
हम आपकी व्यक्तिगत जानकारी की सुरक्षा करते हैं और स्पैम नहीं भेजते।
लेखक के बारे में
Masa
Claude Code का गहराई से उपयोग करने वाले इंजीनियर। claudecode-lab.com चलाते हैं, जो 10 भाषाओं में 2,000 से अधिक पेजों वाला टेक मीडिया है।
संबंधित लेख
Claude Code ke liye 7 CLAUDE.md templates jo aap real projects me copy kar sakte hain
Solo app, content site, API, team repo aur legacy codebase ke liye 7 practical CLAUDE.md templates, plus common failure cases.
Claude Code Approval aur Sandbox Guide | Roz ke kaam ke liye safe settings
Claude Code me allow, ask, deny aur sandbox ko kaise baantna chahiye - practical settings, hooks aur real workflow examples ke saath.
Claude Code की सम्पूर्ण शुरुआती गाइड 2026 | शून्य से प्रोफेशनल उपयोग तक 7 स्टेप्स में
पहली बार Claude Code उपयोग करने वालों के लिए पूरी गाइड। इंस्टॉलेशन से लेकर असली डेवलपमेंट वर्कफ्लो में शामिल करने तक — Masa के शुरुआती अनुभव के आधार पर।