프로젝트 시작 전 CSS 를 정리하는 간단한 방법

nyongho·2021년 8월 8일
1

오늘 배운 내용

목록 보기
36/40

프로젝트 시작 전 CSS 를 정리하는 간단한 방법


최근 나는 React App 을 제작하기 위해 초기화 작업을 진행했고 App.js 컴포넌트에 간단하게 Hello! 문자를 넣은 뒤 서버를 실행했다.

그리고 뭔가 이상한 낌새를 느꼈는데 바로 Hello! 글자에 내가 지정하지 않은 Margin? Padding? 과 같은 속성이 있는 것처럼 보였다.

(자세히보면 왼쪽과 위에 여백이 있는 모습이다.)

나는 완전 백지인 상태에서 프로젝트를 시작하고 싶은데.. 방법이 없을까? 고민하던 찰나에 다음의 사이트를 발견했고 훌륭한 CSS 파일을 발견했다.

CSS Tools: 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;
}

React 의 public 폴더에 reset.css 라는 파일을 만들고 그 파일에 해당 코드를 붙혀넣는다.

그리고 이를 적용시키기 위해 index.html 에 다음의 코드를 넣어준다.

 <link rel="stylesheet" href="%PUBLIC_URL%/reset.css" />

이러면 완벽한 백지 상태에서의 CSS 초기화 작업이 끝나게 된다.

profile
두 줄 소개

0개의 댓글