Typescript 기초 (4) - Reset CSS

Singsoong·2022년 6월 21일
0

Typescript

목록 보기
5/6

📚Reset CSS

  • 프로젝트를 시작하기 전 style 초기화를 하면 편하다.
  • Reset CSS라고 불리는 파일의 내용을 가져오면 된다.

    Reset CSS

  • Reset 파일의 내용(혹은 전체 도큐먼트에 적용할 기본값, 폰트 등)을 전체 도큐먼트에 적용시키려면 Reset 파일을 설치하는것도 되지만, createGlobalStyle을 이용하면 된다.
  • createGlobalStyle은 컴포넌트를 만들 수 있는데, 이 컴포넌트는 렌더링 될 때 전역 스코프에 스타일을 적용시켜준다.
  • 따라서 최상의 컴포넌트인 App에서 Router과 나란히 컴포넌트를 위치시켜주면 GlobalStyle에 정의한 스타일들이 전역적으로 다 적용이 되게 된다.
const GlobalStyle = createGlobalStyle`
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, menu, 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,
main, 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, main, menu, nav, section {
  display: block;
}
/* HTML5 hidden-attribute fix for newer browsers */
*[hidden] {
    display: none;
}
body {
  line-height: 1;
}
menu, 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;
}
`;

function App() {
  return (
    <>
      <GlobalStyle />
      <Router />;
    </>
  );
}

export default App;
  • 아래 코드 내용도 추가로 GlobalStyle에 추가한다.
a{
  text-decoration: none;
}
*{
  box-sizing: border-box;
}

profile
Web Developer

0개의 댓글