Communitygithub.com

반응형 레이아웃

CSS 그리드, 플렉스박스, 컨테이너 쿼리 및 유동적 크기 조정을 사용하여 모바일부터 와이드 데스크톱까지 작동하는 페이지 레이아웃을 구축합니다. 카드 그리드, 벤토 그리드, 분할 섹션, 고정 사이드바 및 접히는 내비게이션을 포함합니다. 누군가 사이트가 "모바일에서 깨진다"고 말하거나, 반응형 그리드, 벤토 레이아웃, 모바일 메뉴, 가로 스크롤 또는 오버플로우 수정을 요청하거나, 다중 열 섹션을 배치할 때 이 스킬을 사용하세요.

반응형 레이아웃란 무엇인가요?

이 스킬은 반응형 CSS 레이아웃을 처음부터 올바르게 구축하기 위한 포괄적인 가이드를 제공합니다. 데스크톱 우선 방식으로 레이아웃을 만든 후 모바일을 패치하는 일반적인 접근 방식 대신, 콘텐츠가 실제로 깨질 때만 중단점을 추가하는 콘텐츠 중심(content-first) 접근 방식을 강조합니다. 스킬은 기본 리셋, 중단점 없는 카드 그리드(auto-fit과 minmax 사용), 분할 섹션(텍스트/미디어), 벤토 그리드(다양한 열/행 스팬), 고정 사이드바가 있는 문서/FAQ 레이아웃, 접히는 헤더와 모바일 메뉴를 포함한 주요 레이아웃 패턴을 위한 즉시 사용 가능한 CSS 코드 조각을 제공합니다. 또한 컨테이너 쿼리를 사용한 컴포넌트 수준의 반응형, 접근성과 사용자 확대/축소를 존중하는 em 기반 중단점, 그리고 일반적인 가로 스크롤 문제의 근본 원인을 식별하고 수정하는 방법(고정 너비, 100vw, 긴 텍스트, flex/grid 오버플로우 등)을 다룹니다. 마지막으로 터치 타겟 크기, viewport 단위(svh/dvh), iOS 입력 줌 방지, 노치 안전 영역 처리에 대한 모범 사례를 포함합니다. 이 스킬은 Claude Code, Cursor, Codex 등 모든 AI 코딩 에이전트와 함께 사용할 수 있습니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/imperfec-t/webcraft/tree/main/skills/responsive-layout

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

반응형 레이아웃은(는) 무엇을 하나요?

레이아웃이 스스로 적응하도록 작성한 다음, 콘텐츠가 실제로 깨지는 지점에만 중단점을 추가하세요. 데스크톱 우선으로 제작한 후 아래로 패치하는 레이아웃이 대부분의 모바일 버그 원인입니다.

기본

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; }
img, video, svg { max-width: 100%; height: auto; display: block; }

.container { width: min(100% - 2 * var(--gutter, 1.25rem), var(--container, 76rem)); margin-inline: auto; }
section { padding-block: var(--section, clamp(4rem, 3rem + 6vw, 9rem)); }

패턴

중단점 없는 카드 그리드

.grid { display: grid; gap: clamp(1rem, 2vw, 2rem);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); }

min(100%, 18rem)은 컨테이너가 최소 너비보다 좁을 때 오버플로우를 막습니다. 짧은 마지막 행이 늘어나지 않아야 한다면 auto-fill을 대신 사용하세요.

분할 섹션 (텍스트 및 미디어)

.split { display: grid; gap: clamp(2rem, 5vw, 5rem); align-items: center; }
@media (min-width: 62em) { .split { grid-template-columns: 1.1fr 0.9fr; }
  .split--flip > :first-child { order: 2; } }

모바일에서는 의도적으로 무엇이 먼저 올지 결정하세요. 보통 텍스트가 먼저 오며, 이미지가 메시지인 경우는 예외입니다.

벤토 그리드

.bento { display: grid; gap: 1rem; grid-template-columns: repeat(6, 1fr); grid-auto-rows: minmax(12rem, auto); }
.bento > .wide  { grid-column: span 4; }
.bento > .half  { grid-column: span 3; }
.bento > .third { grid-column: span 2; }
.bento > .tall  { grid-row: span 2; }
@media (max-width: 61.99em) { .bento { grid-template-columns: repeat(2, 1fr); }
  .bento > * { grid-column: span 1; grid-row: auto; } .bento > .wide { grid-column: span 2; } }
@media (max-width: 35.99em) { .bento { grid-template-columns: 1fr; } .bento > * { grid-column: auto; } }

각 행의 스팬 합계가 열 개수와 일치해야 하며 그렇지 않으면 간격이 생깁니다. 클래스를 작성하기 전에 행을 스케치하세요.

긴 콘텐츠(FAQ, 기사) 옆에 고정 사이드바

.with-aside { display: grid; gap: 3rem; }
@media (min-width: 62em) { .with-aside { grid-template-columns: 22rem 1fr; align-items: start; }
  .with-aside aside { position: sticky; top: 6rem; } }

position: sticky는 조상 요소에 overflow: hidden 또는 auto가 있으면 조용히 실패합니다. 조상에는 대신 overflow: clip을 사용하세요.

헤더 및 모바일 메뉴

  • 데스크톱: 로고, 인라인 내비게이션, CTA. 임의의 너비가 아닌, 내비게이션이 더 이상 들어맞지 않을 때 메뉴 버튼으로 축소합니다.
  • 메뉴 버튼은 실제 <button aria-expanded aria-controls>입니다. 패널은 열려 있는 동안 포커스를 가두고, Escape 키로 닫히며, 버튼으로 포커스를 복원합니다.
  • 열려 있는 동안 배경 스크롤을 잠그고(html에 overflow: hidden), 레이아웃 점프를 방지하기 위해 스크롤바 너비를 고려합니다.
  • 드롭다운은 터치 기기에서 클릭 시 열립니다. 호버만으로는 접근할 수 없습니다.

컴포넌트 수준 반응형

카드가 넓은 그리드와 좁은 사이드바 모두에 나타날 때, 컨테이너 쿼리를 사용하여 카드가 자신의 너비에 반응하도록 합니다:

.card-wrap { container-type: inline-size; }
@container (min-width: 28rem) { .card { display: grid; grid-template-columns: 10rem 1fr; } }

중단점

사용자 확대/축소를 존중하도록 em을 사용하세요. 제안 세트: 36em (576px), 48em (768px), 62em (992px), 75em (1200px). 중단점이 없으면 무엇이 깨지는지 이름을 지을 수 있을 때만 추가하세요.

오버플로우 사냥

모바일에서의 가로 스크롤은 거의 항상 다음 중 하나입니다:

  1. 요소나 이미지의 px 단위 width 고정.
  2. 패딩이 있는 부모 내부의 100vw (100%를 사용하세요).
  3. URL이나 이메일과 같은 긴 중단 없는 텍스트: overflow-wrap: anywhere.
  4. 줄어들지 않는 플렉스 자식: min-width: 0을 추가하세요.
  5. 320px 화면에서 minmax(20rem, 1fr)인 그리드 트랙: 최소값을 min(100%, …)으로 감싸세요.
  6. 뷰포트 밖의 절대 위치 장식: overflow: clip으로 섹션을 클리핑하세요.
  7. 전체 너비 행의 음수 마진.

범인을 찾으려면 콘솔에서 다음을 실행하세요:

[...document.querySelectorAll("*")].filter(e => e.getBoundingClientRect().right > innerWidth + 1)

터치 및 뷰포트 세부 사항

  • 탭 대상은 최소 44x44px, 간격 8px.
  • 전체 높이 섹션에는 vh 대신 svh/dvh를 사용하여 모바일 브라우저 바가 콘텐츠를 자르지 않도록 합니다.
  • 입력 요소는 16px 이상의 글꼴 크기; 더 작으면 iOS가 포커스 시 확대합니다.
  • 노치 존중: padding-inline: max(var(--gutter), env(safe-area-inset-left)).

테스트 너비

320, 390, 768, 1024, 1440 및 1920. 브라우저 확대 200%에서도 테스트하고, 내비게이션에 긴 번역 문자열이 있을 때도 테스트하세요.

Individual skills in this repo

This repo contains 4 individual skills — each has its own dedicated page.

hero-section

Design and build the hero (first screen) of a website, including headline layout, media treatment, CTA, proof badge, marquee and entrance animation. Use this whenever someone asks for a hero section, a landing page header, "the top of my homepage", a cinematic or animated intro, a video background, a text marquee, or says their first screen looks plain or generic.

homepage-blueprint

Plan the section structure and content slots of a homepage for an agency, freelancer, studio or service business before any design or code. Use this whenever someone asks "what sections should my homepage have", "plan my website", "structure a landing page for my business", wants a wireframe or sitemap for a service site, or starts building a homepage without a clear outline.

scroll-motion

Add scroll-driven and entrance animation to a website with GSAP, ScrollTrigger and Lenis, including reveals, parallax, pinned sections, horizontal scroll, line drawing, counters and preloaders. Use this whenever someone wants a site to "feel premium", asks for smooth scrolling, scroll animations, parallax, text reveals, a pinned or sticky scroll section, an animated preloader, or names GSAP, ScrollTrigger, Lenis, Locomotive or AOS.

website-workflow

Plan and sequence a whole website build, from structure through design, code, WordPress and launch, by routing each stage to the right webcraft skill. Use this when someone asks to "build me a website", "design my site from scratch", "redo our homepage", wants an end-to-end plan for a marketing, agency, studio or service site, or the request spans more than one of structure, look, layout, motion, CMS and QA.

관련 스킬