You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
🚀
NavBar
가 오른쪽으로 쏠린 이유: 더 자세한 설명✅
NavBar
가 오른쪽으로 쏠린 이유는 부모 컨테이너의 크기(div
)가 100%가 아니었기 때문이야.✅ 부모 컨테이너가 작으면 NavBar도 그 크기를 따라 작아지고, 중앙 정렬이 되지 않음.
📌 1.
NavBar
가 부모 컨테이너의 크기를 따라가는 원리📍 예제 코드 1 (부모의 너비가 390px으로 제한된 경우)
max-w-[390px]
가 적용됨 → 부모 컨테이너(div
)의 최대 너비가 390px로 제한됨.NavBar
의 너비도 390px로 제한됨.✅ 이 경우
NavBar
는w-full
이 없으면 화면 전체를 채우지 못하고 부모 크기(390px)만큼만 적용됨.✅ 즉, 화면 전체(100%)가 아니라, 부모 컨테이너 크기(390px)에 맞춰 좁아지고 오른쪽으로 쏠리게 됨.
📌 2. 특정
max-width
값이 NavBar에 적용된 경우📍 예제 코드 2 (NavBar 자체에
max-w-[390px]
가 적용된 경우)w-full
이어도, NavBar의 크기는 390px로 제한되므로 화면 전체를 채우지 못함.✅ NavBar는 부모 크기를 따라가므로,
w-full
이 없으면 원하는 크기보다 작아질 수 있음!📌 3. 해결 방법:
w-full
추가max-w
제한이 사라짐.✅ NavBar의 너비가 부모 크기보다 작아지는 걸 방지하려면
w-full
을 추가해야 함!✅ 부모 컨테이너가
max-w-[390px]
이면w-full
이 없을 때 제한된 크기로 쏠릴 수 있음!📌 최종 정리
✅ 결론:
w-full
을 추가하면서 부모 크기를 따라가지 않고, 무조건 가로 전체를 채우게 되어 정렬 문제가 해결된 것! 🎯🚀Beta Was this translation helpful? Give feedback.
All reactions