
- μ»΄ν¬λνΈλ₯Ό κΈ°λ₯λ³λ‘ λ¬Άμ΄μ μ μ
- νλ©΄μ ꡬμ±μ΄λ λ°°μΉ (λ μ΄μμ λμμΈ)
- κ΅΅μ κΈμ¨ λ± νμ΄ν¬κ·ΈλνΌμ μμ μ μ©
- μ λ ¬μ΄λ λ°°μμ λν κ°κ°
- UXμ λν΄ κ³ λ―Όνκ³ , UXκ° μ μ μ©λ μΉμ΄λ μ±μ λΆμν΄ λ³Έ κ²½ν
- μ§κ΄μ μ΄κ³ μ¬μ΄ UI μ μ
body { /*μ
λ ν° λ° μ μΈ λΈλ‘*/
color: red; /*μ μΈ = μμ±λͺ
+ μμ±κ° + μ μΈ κ΅¬λ¬Έμ*/
font-size: 30px;
}
μ
λ ν°(Selector) (μμ μ΄λ¦μ΄λ id, ν΄λμ€ λ± νΉμ μμλ₯Ό μ ν)μ μΈ λΈλ‘(Declaration block)μ μΈ(Declaration)μμ±λͺ
(Property)μμ±κ°(Value)μ μΈ κ΅¬λΆμ(;)<!--html-->
<nav style="background: #eee; color: blue">...</nav>
<!--html-->
<style>
#hello1 {
color: red;
background-color: yellow;
}
</style>
/*css*/
#hello1 {
color: red;
background-color: yellow;
}
<!--html-->
<link rel="stylesheet" href="index.css" />
/*css*/
#hello1 {
color: red;
background-color: yellow;
}
<!--html-->
<style type='text/css'>
@import url("mystyle.css");
</style>
id : κ³ μ (unique)ν μ΄λ¦μ λΆμΌ λ μ¬μ© (μ€λ³΅ νμ© X)class : μ¬λ¬ μμμ λμΌ μ€νμΌμ μ μ©ν λ μ¬μ©| id | class |
|---|---|
| # μΌλ‘ μ ν | . μΌλ‘ μ ν |
| ν λ¬Έμμ λ¨ νλμ μμμλ§ μ μ© | λμΌν κ°μ κ°λ μμμ μ μ© |
| νΉμ μμμ μ΄λ¦μ λΆμ΄λ λ° μ¬μ© | μ€νμΌμ λΆλ₯(classification)μ μ¬μ© |
color : κΈκΌ΄ μμ μμ±.box {
color: #155724; /* κΈμ μμ */
background-color: #d4edda; /* λ°°κ²½ μμ */
border-color: #c3e6cb; /* ν
λ리 μμ */
}
font-family : κΈκΌ΄ μμ±, κΈκΌ΄μ΄ μ‘΄μ¬νμ§ μκ±°λ λλ°μ΄μ€μ λ°λΌ μ§μνμ§ μλ κΈκΌ΄μ΄ μμ μ μμ΄ fallback κΈκΌ΄μ μΆκ°ν μ μμ.emphasize {
font-family: "SF Pro KR", "MalgunGothic", "Verdana";
}
font-size : ν°νΈ ν¬κΈ° μμ±font-weight : ν°νΈ κ΅΅κΈ° μμ±text-decoration : λ°μ€, κ°λ‘μ€ μμ±letter-spacing : μκ° μμ±line-height : νκ° μμ±text-align : κ°λ‘ μ λ ¬ μμ± (left. right, center, justify)<center>, <font>λ₯Ό μ¬μ©νμ§ μμ (HTMLμ ꡬ쑰λ₯Ό μ€κ³νλ μΌλ§ λ΄λΉνκ³ , CSSλ μ€νμΌλ§λ§ λ΄λΉ)px, pt λ±%, em, rem, ch, vw, vh λ±px μ¬μ©rem μ¬μ©emμ λΆλͺ¨ μ리먼νΈμ λ°λΌ μλμ μΌλ‘ ν¬κΈ°κ° λ³κ²½λλ―λ‘ κ³μ°μ΄ μ΄λ €μ. μ΄μ λΉν΄ remμ rootμ κΈμ ν¬κΈ°μ λ°λΌμλ§ μλμ μΌλ‘ λ³ν¨px μ¬μ©vw(viewport width), vh(viewport height) μ¬μ©<body> νκ·Έμμμ %λ HTMLμ΄ μ°¨μ§νλ λͺ¨λ μμ, μ¦ μ§κΈμ 보μ΄μ§ μμΌλ μ€ν¬λ‘€ νμ λ 보μ΄λ μμκΉμ§ ν¬ν¨νμ λ λΉμ¨μ<h1>, <p>, <div> λ±<span> λ± (inlineμ width, height μμ±μ΄ μ μ©λμ§ μμ)| block | inline-block | inline | |
|---|---|---|---|
| μ€λ°κΏ μ¬λΆ | μ€λ°κΏ μΌμ΄λ¨ | μ€λ°κΏ μΌμ΄λμ§ μμ | μ€λ°κΏ μΌμ΄λμ§ μμ |
| κΈ°λ³Έ λλΉ (width) | 100% | κΈμκ° μ°¨μ§νλ λ§νΌ | κΈμκ° μ°¨μ§νλ λ§νΌ |
| width, height μ¬μ© κ°λ₯ μ¬λΆ | κ°λ₯ | κ°λ₯ | λΆκ°λ₯ |

overflow)content-boxλ λ°μ€μ ν¬κΈ°λ₯Ό μΈ‘μ νλ κΈ°λ³Έκ°μ΄λ€.border-boxλ₯Ό κΆμ₯ν¨)<!--html-->
<div id="container">
<div id="inner">
μμͺ½ box
</div>
</div>
/*css*/
#container {
width: 300px;
padding: 10px;
background-color: yellow;
border: 2px solid red;
}
#inner {
width: 100%;
height: 200px;
border: 2px solid green;
background-color: lightgreen;
padding: 30px;
}
ex) #containerμ λλΉλ₯Ό 300pxλ‘ μ§μ νλλ° κ°λ°μ λκ΅¬λ‘ νμΈ μ 324pxμ΄ λλ κ²½μ°
300px (μ½ν μΈ μμ)
+10px (padding-left)
+10px (padding-right)
+2px (border-left)
+2px (border-right)
boder-box/*css*/
* {
box-sizing: border-box;
}
* { }
h1 { }
div { }
section, h1 { }
#μΌλ‘ μμ μ ν#only { }
.μΌλ‘ μμ μ ν.widget { }
.center { }
a[href] { }
p[id="only"] { }
p[class~="out"] { }
p[class|="out"] { }
section[id^="sect"] { }
div[class$="2"] { }
div[class*="w"] { }
header > p { }
<header>
<p> <!-- μ ν -->
<span>
<p></p>
</span>
</p>
<p> <!-- μ ν -->
<span>
<p></p>
</span>
</p>
</header>
header p {}
<header>
<p><!-- μ ν -->
<span>
<p><!-- !!μ ν!! -->
</p>
</span>
</p>
<p><!-- μ ν -->
<span>
<p><!-- !!μ ν!! -->
</p>
</span>
</p>
</header>
section ~ p { }
<header>
<section></section>
<p></p> <!-- μ ν -->
<p></p> <!-- μ ν -->
<p></p> <!-- μ ν -->
</header>
section + p { }
<header>
<section></section>
<p></p> <!-- μ ν -->
<p></p>
<p></p>
</header>
a:link { } /*μ¬μ©μκ° λ°©λ¬Ένμ§ μμ <a>μμλ₯Ό μ ν*/
a:visited { } /*μ¬μ©μκ° λ°©λ¬Έν <a>μμλ₯Ό μ ν */
a:hover { } /* λ§μ°μ€λ₯Ό μμ μμ μ¬λ Έμ λ μ ν */
a:active { } /* νμ±ν λ(ν΄λ¦λ) μνμΌ λ μ ν */
a:focus { } /* ν¬μ»€μ€κ° λ€μ΄μ μμ λ μ ν */
input:checked + span { } /*μ²΄ν¬ μνμΌ λ μ ν */
input:enabled + span { } /*μ¬μ© κ°λ₯ν μνμΌ λ μ ν */
input:disabled + span { } /*μ¬μ© λΆκ°λ₯ν μνμΌ λ μ ν */
p:first-child { } /*p μλ¦¬λ¨ΌνΈ μ€μμ, 첫 λ²μ§Έ μμ μ리먼νΈλ₯Ό μ ν*/
ul > li:last-child { }
ul > li:nth-child(2n) { }
section > p:nth-child(2n+1) { } /*sectionμ μμ μλ¦¬λ¨ΌνΈ μ€μμ, νμ λ²μ§Έ μμ μ리먼νΈκ° pμΈ κ²μ μ ν*/
ul > li:first-child { }
li:last-child { }
div > div:nth-child(4) { }
div:nth-last-child(2) { } /*divμ μμ μλ¦¬λ¨ΌνΈ μ€μμ, λ§μ§λ§μμ λ λ²μ§Έ μ리먼νΈκ° divμΈ κ²μ μ ν*/
section > p:nth-last-child(2n + 1) { }
p:first-of-type { } /*p μ리먼νΈμ νμ μλ¦¬λ¨ΌνΈ μ€ μ²« λ²μ§Έ p μ리먼νΈλ₯Ό μ ν (first-childμλ λ€λ₯΄κ² 첫 λ²μ§Έ μμ μ리먼νΈκ° μλ, μ²μ λ±μ₯νλ pλ₯Ό μ ν)*/
div:last-of-type { }
ul:nth-of-type(2) { }
p:nth-last-of-type(1) { }
input:not([type="password"]) { }
div:not(:nth-of-type(2)) { }
input[type="text"]:valid { }
input[type="text"]:invalid { }
μ λ ν° μ°μ΅ κ²μ
- https://ko.wikipedia.org/wiki/%EA%B4%80%EC%8B%AC%EC%82%AC_%EB%B6%84%EB%A6%AC
- https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units#numbers_lengths_and_percentages
- https://fresh-mint.tistory.com/entry/css-Pseudo-classes-Selector-%EA%B0%80%EC%83%81-%ED%81%B4%EB%9E%98%EC%8A%A4-%EC%84%A0%ED%83%9D%EC%9E%90