갈푸라떼
갈푸라떼는 개발중
갈푸라떼
전체 방문자
오늘
어제
  • 분류 전체보기 (232)
    • CS (0)
      • CSinfo (0)
    • Frontend (15)
      • HTML,CSS (1)
      • Javascript (2)
      • React (0)
      • React Hook (12)
    • Backend (0)
      • Python (0)
      • Node.js (0)
      • php (0)
    • DB (2)
      • MySQL (2)
      • BigQuery (0)
      • Mongodb (0)
    • Study (186)
      • JavaScript (72)
      • JavaScript(Clean code) (50)
      • Node.js (11)
      • HTML,CSS (13)
      • React (30)
      • TypeScript (10)
      • React-Native (0)
    • Error (2)
      • error (2)
    • Git (22)
      • Git (22)
    • Help Coding (4)
      • Useful websites (3)

블로그 메뉴

  • 홈
  • 태그
  • 방명록
  • Github

공지사항

인기 글

태그

  • this
  • structure
  • Arrow
  • 인터프리터
  • 프로토타입
  • 심볼
  • 원시타입
  • class
  • PM2
  • Babel
  • 객체타입
  • 오버라이딩
  • ECMAScript
  • SPREAD
  • 상속
  • 컴파일러
  • 렉시컬 환경
  • 스코프 체인
  • nodemon
  • symbol
  • 실행 컨텍스트
  • 정적 레벨
  • 이터러블
  • 자바스크립트엔진
  • prototype
  • 호이스팅
  • 네이밍
  • 함수
  • 싱글스레드
  • function

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
갈푸라떼

갈푸라떼는 개발중

Study/React

[React_study] reset css 하는 방법 + npm으로 설치

2022. 6. 18. 20:06

* reset css를 하는 이유

브라우저마다 태그를 렌더링하는 기본 스타일이 다르고, 기본 padding,margin값들 이 적용되어 있는 부분을 초기화 하기위해
style 기본값을 0으로 만들고 list,a태그에 기본적으로 적용된 스타일들의 초기화를 위해 reset css를 해준다.

[결론적으로는] 크로스 브라우징을 위해 브라우저마다 다른 기본값들에 대한 차이를 없애는것이다

 

* 기존에 사용하던 방법 ( css 파일 추가 )

https://meyerweb.com/eric/tools/css/reset/index.html

  • 가장 많이 사용 하는 Reset css
/* 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;
}

* npm으로 설치하는 방법

// yarn
$ yarn add styled-reset

// npm 
$ npm i styled-reset

*  App.js 파일에 아래처럼 적어줌

import * as React from 'react'
import { Reset } from 'styled-reset'

const App = () => (
  <React.Fragment>
    <Reset />
    <div>Hi, I'm an app!</div>
  </React.Fragment>
)

* Reset.css이외에 전역적인 스타일을 주는 방법

// GlobalStyle.js

import { createGlobalStyle } from "styled-components";
import reset from "styled-reset";

const GlobalStyle = createGlobalStyle`
  ${reset}
  /* other styles */
`;

export default GlobalStyle;

 

// App.js

import * as React from 'react'
import { Reset } from 'styled-reset'
import GlobalStyle from "./GlobalStyle";

const App = () => (
  <React.Fragment>
    <GlobalStyle />
    <div>Hi, I'm an app!</div>
  </React.Fragment>
)

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

[React_study] styled-components를 이용한 dark/light모드  (0) 2022.07.20
[React_study] 터미널 / 브라우저 콘솔창에 warning  (0) 2022.06.20
[React_study] Redux state가 object/array일 경우 변경 방법  (0) 2022.06.15
[React_study] Redux store의 state 변경  (0) 2022.06.12
[React_study] Redux store에 state 보관 & 호출  (0) 2022.06.12
    'Study/React' 카테고리의 다른 글
    • [React_study] styled-components를 이용한 dark/light모드
    • [React_study] 터미널 / 브라우저 콘솔창에 warning
    • [React_study] Redux state가 object/array일 경우 변경 방법
    • [React_study] Redux store의 state 변경
    갈푸라떼
    갈푸라떼

    티스토리툴바