어이 당신. 혹시 nextjs에서 styled-component를 사용하기 위해 죄다 use client를 박고 있지 않은가?
용기를 가지고 tailwindcss로 마이그레이션을 진행하다 reset css가 둘이 달라서 레이아웃이 다 뭉개지지 않는가?
바로 그게 접니다.
tailwind의 base layer에서 초기화 해주지만 reset css와 스타일이 조금씩 다르다
때문에 base를 재적용하고 덮어씌웠다
/* global.css */
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
/* Reset styles */
html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
menu,
nav,
section {
display: block;
}
body {
line-height: 1;
}
ol,
ul {
list-style: none;
}
blockquote,
q {
quotes: none;
}
blockquote:before,
blockquote:after,
q:before,
q:after {
content: "";
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
그리고 런타임에 적용되는 styled-component의 globalStyle에서 때리는 ${reset}은
https://meyerweb.com/eric/tools/css/reset/
과 동일하다.
이제 레이아웃 안 뭉개지면서 tailwindcss로 마이그레이션 가능.
내가 20000줄 어치 마이그레이션 하는동안 문제 없었으니 믿고 사용해도 됨
'<frontend>' 카테고리의 다른 글
javascript 비동기 순서보장 잡기술 (0) | 2024.09.29 |
---|---|
트레이딩뷰 무료 고급 차트 라이브러리 신청&사용 (1) | 2024.09.29 |
React에서 동적인 key 왜 필요할까? (5) | 2024.09.20 |