Reset CSS
My-Reset CSS
1. Eric Meyerโs CSS reset ๐ฉโ๐ป
๋ธ๋ผ์ฐ์ ๋ง๋ค ๊ธฐ๋ณธ ์คํ์ผ์ด ๋ค๋ฅด๊ณ , ๋ถํ์ํ ์คํ์ผ๋ ๋ง์์ ๊ฐ๊ธ์ ์ด๋ฉด ๋ฆฌ์
์์ผ์ฃผ๋ ๊ฒ์ด ์คํ์ผ์ ์์ฑํ๊ธฐ ์ฝ๊ณ , ํฌ๋ก์ค ๋ธ๋ผ์ฐ์ง์ ๋์์
์ค๋ค. ์ด๊ฒ์ Reset CSS ๋ผ ํ๋๋ฐ ๋๋ถ๋ถ์ Reset CSS ๋ Eric Meyer
๊ฐ ์ ์ํ ๊ฒ์ ๊ธฐ์ค์ผ๋ก ํ๊ณ ์๋ค.
2. Create CSS File ๐ฉโ๐ป
์ฒซ ๋ฒ์งธ ๋ฐฉ๋ฒ์ ์ง์ CSS ํ์ผ์ ๋ง๋๋ ๊ฒ์ด๋ค.
meyerweb ์์ ๋ค์๊ณผ ๊ฐ์ 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;
}
๋ฌผ๋ก , ๋๋ถ๋ถ์ ๊ฒฝ์ฐ ์ด๊ฒ๋ง์ผ๋ก ์ถฉ๋ถํ์ง ์์์ ๊ฐ์ธ์ ์ผ๋ก ๊ณตํต์ผ๋ก ์ ์ฉํ๊ณ ์ถ์ ์คํ์ผ์ ํจ๊ป reset ์ ์ถ๊ฐํ๋ ํธ์ด๋ค.
a {
text-decoration: none;
color: inherit;
}
* {
box-sizing: border-box;
}
input, textarea {
-moz-user-select: auto;
-webkit-user-select: auto;
-ms-user-select: auto;
user-select: auto;
}
input:focus {
outline: none;
}
button {
border: none;
background: none;
padding: 0;
cursor: pointer;
}
์ด ๋์ ํฉ์ณ ์ง์ reset.css
ํ์ผ์ ์์ฑํด ๋ฃ์ด ์ ๊ณตํด ์คํ์ผ์ ์ด๊ธฐํ ์ํฌ ์ ์๋ค.
- Customized
reset.css
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;
}
a {
text-decoration: none;
color: inherit;
}
* {
box-sizing: border-box;
}
input, textarea {
-moz-user-select: auto;
-webkit-user-select: auto;
-ms-user-select: auto;
user-select: auto;
}
input:focus {
outline: none;
}
button {
border: none;
background: none;
padding: 0;
cursor: pointer;
}
3. JSDelivery ๐ฉโ๐ป
JSDelivery CDN ์์ ์ ๊ณตํ๋ ๊ฒ์ CDN ์์ ์ง์ ๊ฐ์ ธ๋ค ์ฌ์ฉํ๊ฑฐ๋ npm ์ผ๋ก ์ค์นํด์ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ด๋ค. ๋ฌผ๋ก , ์ด ๋ฐฉ๋ฒ
์ญ์ Eric Meyer
์ Reset CSS ๋ฅผ ์ฌ์ฉํด ๋ง๋ค์ด์ก๋ค.
CDN ์ ์ฌ์ฉํ ๊ฒฝ์ฐ JSDelivr ๋ฅผ ๋ฐฉ๋ฌธํด ์ต์ ๋ฒ์ ์ ํ์ธ ํ ํ๋ก์ ํธ์ ์ถ๊ฐํ๋ฉด ๋๋ค.
<!-- static version -->
<link href="https://cdn.jsdelivr.net/npm/reset-css@5.0.2/reset.min.css" rel="stylesheet">
<!-- latest minor -->
<link href="https://cdn.jsdelivr.net/npm/reset-css@5/reset.min.css" rel="stylesheet">
<!-- latest major -->
<link href="https://cdn.jsdelivr.net/npm/reset-css/reset.min.css" rel="stylesheet">
์ด ์ธ์๋ npm
, yarn
, bower
๋ฅผ ์ฌ์ฉํ ์ค์น๋ฅผ ์ ๊ณตํ๋ฉฐ, ์ฌ๋ฌ ์คํ์ผ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ํตํฉ์ ์ ๊ณตํ๋ค.
npm i reset-css
yarn add reset-css
bower install reset-css
- CSS
@import '/path/to/reset-css/reset.css';
- PostCSS and
postcss-import
@import 'reset-css';
- webpack and
css-loader
import 'reset-css';
- Less
@import '/path/to/reset-css/less/reset';
- Sass
@import '/path/to/reset-css/sass/reset';
์ดํ ์ถ๊ฐ๋ก ์ฒ๋ฆฌํ๊ณ ์ ํ๋ ๋ฆฌ์ ์คํ์ผ์ ์์ฑํ๋ฉด ๋๋ค.
a {
text-decoration: none;
color: inherit;
}
* {
box-sizing: border-box;
}
input, textarea {
-moz-user-select: auto;
-webkit-user-select: auto;
-ms-user-select: auto;
user-select: auto;
}
input:focus {
outline: none;
}
button {
border: none;
background: none;
padding: 0;
cursor: pointer;
}
4. Styled Reset ๐ฉโ๐ป
Styled Components ๋ฅผ ์ฌ์ฉํ ๋ ์ปดํฌ๋ํธ ๋ฐฉ์์ผ๋ก ์ ๊ณตํ๊ธฐ ์ํด ์ฌ์ฉํ๋ฉฐ, ์ญ์ Eric Meyer
์ Reset CSS ๋ฅผ ์ฌ์ฉํด
๋ง๋ค์ด์ก๋ค.
Styled Components ๋ฒ์ ์ ๋ฐ๋ผ ์ฌ์ฉ ๋ฐฉ์์ด ์กฐ๊ธ์ฉ ๋ณ๊ฒฝ๋๋ NPM JS ๋ฅผ ๋ฐฉ๋ฌธํด ํ์ฌ ๋ฒ์ ๊ณผ ์ผ์นํ๋ ์ฌ์ฉ ๋ฐฉ๋ฒ์ธ์ง ํ์ธํ๋๋ก ํ๋ค. ๋ค์์ Styled Components 4+ ๋ฅผ ๊ธฐ์ค์ผ๋ก ์ค๋ช ํ๋ค.
npm i styled-reset
์ด ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ reset-css
๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๋ฌ๋ฆฌ Styled Components ๋ก ์์ฑํ ์ปดํฌ๋ํธ๋ฅผ ์ฑ์ ์ถ๊ฐํ๋ ๋ฐฉ์์ผ๋ก ์ฌ์ฉ๋๋ฉฐ,
์ฌ์ฉ ๋ฐฉ๋ฒ์ ๋ ๊ฐ์ง๊ฐ ์๋ค.
1. Reset component
๊ธฐ๋ณธ์ ์ผ๋ก ์ ๊ณต๋๋ Eric Meyer ์ Reset CSS ๋ง ์ ์ฉํ๊ณ ์ ํ ๊ฒฝ์ฐ ๊ธฐ๋ณธ ์ ๊ณต๋๋ ์ปดํฌ๋ํธ๋ฅผ ์ฌ์ฉํ๋ฉด ๋๋ค.
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import { Reset } from "styled-reset";
import { BrowserRouter } from "react-router-dom";
const root = ReactDOM.createRoot(document.getElementById("app-root") as HTMLElement);
root.render(
<React.StrictMode>
<Reset />
<BrowserRouter>
<App />
</BrowserRouter>
</React.StrictMode>,
);
2. createGlobalStyle
๋ณ๋์ CSS ํ์ผ์ ์์ฑํ์ง ์๊ณ Styled Components ๋ง์ ์ฌ์ฉํด ์์ ๋ Reset CSS ๋ฅผ ์ ๊ณตํ๊ณ ์ ํ ๊ฒฝ์ฐ ์ ๊ณต๋๋ ๋ฉ์๋๋ฅผ ์ฌ์ฉํด ํ์ฅ์ํฌ ์ ์๋ค.
import { createGlobalStyle } from "styled-components";
import reset from "styled-reset";
const GlobalStyle = createGlobalStyle`
${reset}
a {
text-decoration: none;
color: inherit;
}
* {
box-sizing: border-box;
}
input, textarea {
-moz-user-select: auto;
-webkit-user-select: auto;
-ms-user-select: auto;
user-select: auto;
}
input:focus {
outline: none;
}
button {
border: none;
background: none;
padding: 0;
cursor: pointer;
}
`;
export default GlobalStyle;
import React from "react";
import GlobalStyle from "./GlobalStyle";
function App() {
return (
<>
<GlobalStyle />
<div>Hi, I'm an app!</div>
</>
);
}
export default App;