Claude Code के साथ Flexbox
Claude Code का उपयोग करके flexbox सीखें। Practical tips और code examples शामिल हैं।
Flexboxの頻出patternको Claude Code से一気にimplementation
Flexboxは1अगला元layoutの定番技術 है।Claude Codeにimplementationを依頼するとき、よくuse करनाpatternを知っておくと指示がspecificallyなり、より正確な結果を得られ है।
navigationバー
> Flexboxでresponsiveなnavigationバーをबनाओ。
> ロゴबाएं寄せ、menuदाएं寄せ、モバイルでハンバーガーmenu。
/* headernavigation */
.navbar {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 1.5rem;
height: 60px;
}
.navbar__logo {
flex-shrink: 0;
}
.navbar__menu {
display: flex;
gap: 1.5rem;
list-style: none;
}
.navbar__actions {
display: flex;
align-items: center;
gap: 0.75rem;
margin-left: auto;
}
センタリングpattern
/* 完全में央配置 */
.center-perfect {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
}
/* テキストとiconの垂直में央揃え */
.inline-center {
display: flex;
align-items: center;
gap: 0.5rem;
}
/* 複数行テキストのमें央配置 */
.text-center-block {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
}
cardlayout
/* 等幅card */
.card-row {
display: flex;
gap: 1.5rem;
}
.card-row .card {
flex: 1;
min-width: 0; /* テキスト溢れ防止 */
}
/* footer固定card */
.card {
display: flex;
flex-direction: column;
height: 100%;
}
.card__body {
flex: 1; /* 残りのスペースを占有 */
}
.card__footer {
margin-top: auto; /* 常にनीचेに配置 */
}
Holy Graillayout
/* 伝統的な3columnlayout */
.holy-grail {
display: flex;
flex-direction: column;
min-height: 100vh;
}
.holy-grail__body {
display: flex;
flex: 1;
}
.holy-grail__main {
flex: 1;
min-width: 0;
padding: 1.5rem;
}
.holy-grail__sidebar {
flex: 0 0 250px;
padding: 1.5rem;
}
.holy-grail__sidebar--left {
order: -1;
}
Sticky Footer
/* footerを常にpageनीचे部に */
.page-wrapper {
display: flex;
flex-direction: column;
min-height: 100vh;
}
.page-content {
flex: 1;
}
/* footer は自動的にनीचे部に */
タグ・チップのラップ配置
/* タグlist */
.tag-list {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
.tag {
flex-shrink: 0;
padding: 0.25rem 0.75rem;
border-radius: 9999px;
font-size: 0.875rem;
background: #e5e7eb;
}
入力fieldとbuttonの結合
/* searchバー */
.search-bar {
display: flex;
}
.search-bar__input {
flex: 1;
border: 1px solid #d1d5db;
border-right: none;
border-radius: 0.5rem 0 0 0.5rem;
padding: 0.5rem 1rem;
min-width: 0;
}
.search-bar__button {
flex-shrink: 0;
border-radius: 0 0.5rem 0.5rem 0;
padding: 0.5rem 1rem;
background: #3b82f6;
color: white;
}
responsive切り替え
/* デスクトップ:横並び → モバイル:縦並び */
.responsive-flex {
display: flex;
flex-direction: column;
gap: 1rem;
}
@media (width >= 768px) {
.responsive-flex {
flex-direction: row;
}
}
/* 逆順display(モバイルで画像をऊपरに) */
@media (width < 768px) {
.feature-section {
flex-direction: column-reverse;
}
}
Flexboxのdebug Tips
/* debug用:全要素にborder */
.debug-flex * {
outline: 1px solid rgba(255, 0, 0, 0.2);
}
/* 各アイテムのsizeを視覚化 */
.debug-flex > * {
position: relative;
}
.debug-flex > *::after {
content: attr(class) " | " attr(style);
position: absolute;
top: 0;
left: 0;
font-size: 10px;
background: rgba(0, 0, 0, 0.7);
color: white;
padding: 2px 4px;
}
Summary
FlexboxはCSS Gridと使い分ける बातがポイント है।1अगला元のlayoutにはFlexbox、2अगला元のlayoutにはCSS Gridが適してい है।Claude Codeに「Flexboxで横並びにして」と指示する से ही、gapsettingsやmin-width: 0の考慮 तक शामिलimplementation generateしてくれ है।CSSvariable के साथ combineてデザインtokenをutilizationするのもおすすめ है।Flexboxの仕様詳細はCSS Flexible Box Layout Module confirmして करें।
मुफ़्त 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 के शुरुआती अनुभव के आधार पर।