Web Devlopment/NextJs
#10. global css
키모형
2025. 3. 29. 14:53
반응형
프로젝트 전체에 대한 global css를 적용하고 싶다면 먼저 global.css를 작성
(1) /app/styles/global.css 생성
reset css 를 포함하여 프로젝트 전체에 적용할 스타일을 작성
https://meyerweb.com/eric/tools/css/reset/
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
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;
}
/*
custom css
*/
body {
padding: 10px;
font-family:
system-ui,
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
Roboto,
Oxygen,
Ubuntu,
Cantarell,
"Open Sans",
"Helvetica Neue",
sans-serif;
background-color: black;
color: white;
font-size: 18px;
}
a {
color: inherit;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
(2) /app/layout.tsx 에 global.css import
import "./styles/global.css";
(3) 개별 page, component 에 css를 적용하려면
name.module.css 형식으로 파일을 작성하여 styles 폴더에 넣고 필요한 페이지에 import 하여 적용
예) navigation.module.css - /app/components/navigation.tsx 에 적용할 css
css 적용된 모습
반응형