Flexbox: Claude Code 활용 가이드
flexbox: Claude Code 활용. 실용적인 팁과 코드 예시를 포함합니다.
Flexboxの頻出パターンをClaude Code로一気に구현
Flexboxは1次元레이아웃の定番技術です。Claude Code에구현を依頼するとき、よく使うパターンを知っておくと指示が구체적으로なり、より正確な結果を得られます。
내비게이션バー
> Flexboxで반응형な내비게이션バー를 생성해줘。
> ロゴ左寄せ、메뉴右寄せ、モバイルでハンバーガー메뉴。
/* ヘッダーナビゲーション */
.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;
}
センタリングパターン
/* 完全中央配置 */
.center-perfect {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
}
/* テキストとアイコンの垂直中央揃え */
.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;
}
カード레이아웃
/* 等幅カード */
.card-row {
display: flex;
gap: 1.5rem;
}
.card-row .card {
flex: 1;
min-width: 0; /* テキスト溢れ防止 */
}
/* フッター固定カード */
.card {
display: flex;
flex-direction: column;
height: 100%;
}
.card__body {
flex: 1; /* 残りのスペースを占有 */
}
.card__footer {
margin-top: auto; /* 常に下に配置 */
}
Holy Grail레이아웃
/* 伝統的な3カラムレイアウト */
.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
/* フッターを常にページ下部に */
.page-wrapper {
display: flex;
flex-direction: column;
min-height: 100vh;
}
.page-content {
flex: 1;
}
/* footer は自動的に下部に */
タグ・チップのラップ配置
/* タグ一覧 */
.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;
}
입력フィールドと버튼の結合
/* 検索バー */
.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-flex {
display: flex;
flex-direction: column;
gap: 1rem;
}
@media (width >= 768px) {
.responsive-flex {
flex-direction: row;
}
}
/* 逆順表示(モバイルで画像を上に) */
@media (width < 768px) {
.feature-section {
flex-direction: column-reverse;
}
}
Flexboxの디버깅 Tips
/* デバッグ用:全要素にボーダー */
.debug-flex * {
outline: 1px solid rgba(255, 0, 0, 0.2);
}
/* 各アイテムのサイズを視覚化 */
.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;
}
정리
FlexboxはCSS Gridと使い分けることがポイントです。1次元の레이아웃にはFlexbox、2次元の레이아웃にはCSS Gridが適しています。Claude Code에「Flexboxで横並びにして」と指示する만으로、gap설정やmin-width: 0の考慮まで含めた구현を생성してくれます。CSS변수と組み合わせてデザイン토큰を활용するのもおすすめです。Flexboxの仕様상세 정보는CSS Flexible Box Layout Module를 확인하세요.
#Claude Code
#Flexbox
#CSS
#レイアウト
#frontend
Related Posts
Tips & Tricks
Tips & Tricks
Claude Code 생산성을 3배로 높이는 10가지 팁
Claude Code를 더 효과적으로 활용하는 10가지 실전 팁을 공개합니다. 프롬프트 전략부터 워크플로 단축키까지, 오늘부터 바로 적용해 보세요.
Tips & Tricks
Tips & Tricks
Canvas/WebGL Optimization: Claude Code 활용 가이드
canvas/webgl optimization: Claude Code 활용. 실용적인 팁과 코드 예시를 포함합니다.
Tips & Tricks
Tips & Tricks
Markdown Implementation: Claude Code 활용 가이드
markdown implementation: Claude Code 활용. 실용적인 팁과 코드 예시를 포함합니다.