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 देखें।
Related Posts
Claude Code से Productivity 3 गुना बढ़ाने की 10 Tips
Claude Code से ज़्यादा पाने की 10 practical tips जानें। Prompt strategies से workflow shortcuts तक, ये techniques आज से ही आपकी efficiency boost करेंगी।
Claude Code के साथ Canvas/WebGL Optimization
Claude Code का उपयोग करके Canvas/WebGL optimization के बारे में जानें। Practical tips और code examples शामिल हैं।
Claude Code के साथ Markdown Implementation
Claude Code का उपयोग करके markdown implementation सीखें। Practical tips और code examples शामिल हैं।