Frontend/React

[React] CSS Reset

khakhalog 2023. 1. 8. 15:24

styled-components의 createGlobalStyle을 사용해서 전역스타일을 지정해줄 수 있다.

각 컴포넌트의 스타일을 지정해주기 전에 브라우저에 기본 적용된 css를 리셋해주었다.

https://styled-components.com/docs/api#createglobalstyle

 

styled-components: API Reference

API Reference of styled-components

styled-components.com

 

App.js

function App() {
  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, 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;
    }
  `;

  return (
    <>
      <GlobalStyle />
      <Router />
    </>
  );
}
export default App;

'Frontend > React' 카테고리의 다른 글

[React] React Query 톺아보기  (0) 2023.07.25
[React] Styledcomponents S-dot naming  (1) 2023.07.05
[React] Typescript + Inline style  (1) 2023.07.05
[React] Context API  (1) 2023.07.03
[React] React Router Dom V6.4  (0) 2023.05.19