Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
Tags
- 이벤트위임
- 전역변수
- map()
- async
- 중앙정렬
- 돔조작
- 어웨이트
- text-align
- falsy
- 논리연산자
- 자바스크립트기초
- 버블링
- js
- addEventListener
- 지역변수
- 단락회로평가
- 동기적
- 코딩공부
- icoMoon
- truthy
- 비동기적
- git
- 리액트
- 자바스크립트
- 프론트엔드
- 캡쳐링
- 비구조화
- INCLUDES
- Await
- 이벤트리스너
Archives
- Today
- Total
피리부는 사나이 (pied piper)
[ResetCSS] Normalize CSS + 커스텀 보강 = 완벽 본문
* {
margin: 0;
font-family: 'Noto Sans KR', sans-serif;
box-sizing: border-box;
}
html {
font-family: 'Noto Sans KR', sans-serif;
// html에 본문 폰트 사이즈에 패밀리를 보통 준다.
}
body {
font-family: 'Noto Sans KR', sans-serif;
}
h1 {
margin: 0;
}
a {
color: inherit;
// anchor에 속해있는 것의 값을 상속받겠다는 이야기
// ex) p태그 (파란색) 안에 감싸져있으면 a도 파란색
text-decoration: none;
}
button,
input,
textarea,
select {
background-color: transparent;
// 버튼이나 셀렉트 배경 삭제
border: 0;
&:focus {
outline: none;
box-shadow: 0;
}
// 포커스 했을 떄 생기는 더러운 것 없애는 방법
}
a,
button {
cursor: pointer;
}
ul, ol {
padding-left: 0;
list-style: none;
}
에릭 마이어의 Reset CSS만 써왔었는데
최근에 좋은 강의를 듣고 특별히 신경 써야할 프로젝트에는 좀더 공을 들여서
Noramlize CSS + 약간의 추가적인 CSS 설정을 통해 완벽에 가까운 Reset CSS를 세팅할 수 있다는 것을 알았다.
1. Noramlize CSS
출처 : https://necolas.github.io/normalize.css/
// scss-lint:disable all
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
/* Document
========================================================================== */
/**
* 1. Correct the line height in all browsers.
* 2. Prevent adjustments of font size after orientation changes in iOS.
*/
html {
line-height: 1.15; /* 1 */
-webkit-text-size-adjust: 100%; /* 2 */
}
/* Sections
========================================================================== */
/**
* Remove the margin in all browsers.
*/
body {
margin: 0;
}
/**
* Render the `main` element consistently in IE.
*/
main {
display: block;
}
/**
* Correct the font size and margin on `h1` elements within `section` and
* `article` contexts in Chrome, Firefox, and Safari.
*/
h1 {
font-size: 2em;
margin: 0.67em 0;
}
/* Grouping content
========================================================================== */
/**
* 1. Add the correct box sizing in Firefox.
* 2. Show the overflow in Edge and IE.
*/
hr {
box-sizing: content-box; /* 1 */
height: 0; /* 1 */
overflow: visible; /* 2 */
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
pre {
font-family: monospace, monospace; /* 1 */
font-size: 1em; /* 2 */
}
/* Text-level semantics
========================================================================== */
/**
* Remove the gray background on active links in IE 10.
*/
a {
background-color: transparent;
}
/**
* 1. Remove the bottom border in Chrome 57-
* 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
*/
abbr[title] {
border-bottom: none; /* 1 */
text-decoration: underline; /* 2 */
text-decoration: underline dotted; /* 2 */
}
/**
* Add the correct font weight in Chrome, Edge, and Safari.
*/
b,
strong {
font-weight: bolder;
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
code,
kbd,
samp {
font-family: monospace, monospace; /* 1 */
font-size: 1em; /* 2 */
}
/**
* Add the correct font size in all browsers.
*/
small {
font-size: 80%;
}
/**
* Prevent `sub` and `sup` elements from affecting the line height in
* all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
/* Embedded content
========================================================================== */
/**
* Remove the border on images inside links in IE 10.
*/
img {
border-style: none;
}
/* Forms
========================================================================== */
/**
* 1. Change the font styles in all browsers.
* 2. Remove the margin in Firefox and Safari.
*/
button,
input,
optgroup,
select,
textarea {
font-family: inherit; /* 1 */
font-size: 100%; /* 1 */
line-height: 1.15; /* 1 */
margin: 0; /* 2 */
}
/**
* Show the overflow in IE.
* 1. Show the overflow in Edge.
*/
button,
input { /* 1 */
overflow: visible;
}
/**
* Remove the inheritance of text transform in Edge, Firefox, and IE.
* 1. Remove the inheritance of text transform in Firefox.
*/
button,
select { /* 1 */
text-transform: none;
}
/**
* Correct the inability to style clickable types in iOS and Safari.
*/
button,
[type="button"],
[type="reset"],
[type="submit"] {
-webkit-appearance: button;
}
/**
* Remove the inner border and padding in Firefox.
*/
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
border-style: none;
padding: 0;
}
/**
* Restore the focus styles unset by the previous rule.
*/
button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring {
outline: 1px dotted ButtonText;
}
/**
* Correct the padding in Firefox.
*/
fieldset {
padding: 0.35em 0.75em 0.625em;
}
/**
* 1. Correct the text wrapping in Edge and IE.
* 2. Correct the color inheritance from `fieldset` elements in IE.
* 3. Remove the padding so developers are not caught out when they zero out
* `fieldset` elements in all browsers.
*/
legend {
box-sizing: border-box; /* 1 */
color: inherit; /* 2 */
display: table; /* 1 */
max-width: 100%; /* 1 */
padding: 0; /* 3 */
white-space: normal; /* 1 */
}
/**
* Add the correct vertical alignment in Chrome, Firefox, and Opera.
*/
progress {
vertical-align: baseline;
}
/**
* Remove the default vertical scrollbar in IE 10+.
*/
textarea {
overflow: auto;
}
/**
* 1. Add the correct box sizing in IE 10.
* 2. Remove the padding in IE 10.
*/
[type="checkbox"],
[type="radio"] {
box-sizing: border-box; /* 1 */
padding: 0; /* 2 */
}
/**
* Correct the cursor style of increment and decrement buttons in Chrome.
*/
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto;
}
/**
* 1. Correct the odd appearance in Chrome and Safari.
* 2. Correct the outline style in Safari.
*/
[type="search"] {
-webkit-appearance: textfield; /* 1 */
outline-offset: -2px; /* 2 */
}
/**
* Remove the inner padding in Chrome and Safari on macOS.
*/
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
/**
* 1. Correct the inability to style clickable types in iOS and Safari.
* 2. Change font properties to `inherit` in Safari.
*/
::-webkit-file-upload-button {
-webkit-appearance: button; /* 1 */
font: inherit; /* 2 */
}
/* Interactive
========================================================================== */
/*
* Add the correct display in Edge, IE 10+, and Firefox.
*/
details {
display: block;
}
/*
* Add the correct display in all browsers.
*/
summary {
display: list-item;
}
/* Misc
========================================================================== */
/**
* Add the correct display in IE 10+.
*/
template {
display: none;
}
/**
* Add the correct display in IE 10.
*/
[hidden] {
display: none;
}
2. 추가적인 CSS 설정
* {
margin: 0;
font-family: 'Noto Sans KR', sans-serif;
box-sizing: border-box;
}
html {
font-family: 'Noto Sans KR', sans-serif;
// html에 본문 폰트 사이즈에 패밀리를 보통 준다.
}
body {
font-family: 'Noto Sans KR', sans-serif;
}
// 전체, html, body 세 번에 걸쳐서 한 이유는 종종 font-family가 안먹히는 경우가 있어서
// 확실하게 해주기 위해 강력히 세팅해 놓는 것
h1 {
margin: 0;
}
// normalize.css를 그대로 쓰면 h1에 마진 값이 0.67em 0로 세팅되어 있는 것을 볼 수 있다.
// 그래서 여기서 추가적으로 margin 0을 선언해서 margin을 0으로 변경해줘야함
// **그런데 왜 위에다가 margin:0을 했는데 또 하는가?
// 전체를 선택하는 "*" (아스테리스크 또는 공통선택자)는 선택자 우선순위 계산에서 가장 낮다 (값=0)
// 그러므로 먼저 normalize.css에 선택자 우위계산에서 더 높은 점수를 가진 "h1" (태그선택자, 값=1)를 선언해서 줘야 바뀜
a {
color: inherit;
// anchor에 속해있는 것의 값을 상속받겠다는 이야기
// ex) p태그 (파란색) 안에 감싸져있으면 a도 파란색
text-decoration: none;
// a태그 디폴트인 '밑줄' 제거
}
button,
input,
textarea,
select {
background-color: transparent;
// 버튼이나 셀렉트 배경 삭제
border: 0;
// 폼 요소 태그는 border와 background가 너무 ugly함
// 그래서 이 두 가지를 세팅해주는 것이 보기에 좋음
&:focus {
outline: none;
box-shadow: 0;
}
// 포커스 했을 떄 생기는 테두리까지 없애는 방법
}
a,
button {
cursor: pointer;
}
// 마우스 갖다 댔을 때 커서 표시
ul, ol {
padding-left: 0;
list-style: none;
}
// 리스트 역시 기본 스타일이 현재 아무도 안 쓰는 스타일, 안 멋진 점이 앞에 항상 있음
// 또한 ul이 가지고 있는 기본적 padding-left값을 0으로 리셋해줘야 함
이 두 가지를 각각
normalize.css 파일과 _reset.css 파일에 복붙하고
main.css와 연결해서 사용하면 됨
'CSS' 카테고리의 다른 글
[CSS] Svg 파일을 아이콘 폰트로 만들기 (0) | 2022.08.11 |
---|---|
[CSS] 그리드 시스템 (0) | 2022.06.06 |
[CSS] float (0) | 2022.04.22 |
[CSS] inline, inline-block (0) | 2022.04.20 |
[CSS] Flexbox 전반적인 팁 (0) | 2022.04.20 |
Comments