μ μ© μ°μ μμ
!important
- μΈλΌμΈ μ€νμΌ κ·μΉ
- id κ·μΉ
- class κ·μΉ
- μμ κ·μΉ
μμ
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>μμ(inherit)</title>
<style>
div{
color:red;
}
</style>
</head>
<body>
<div>
<p>inherit</p>
</div>
</body>
</html>
λ¨μ
- μ λ λ¨μ : μ΄λ€ νκ²½μ΄λΌλ λμΌν ν¬κΈ°λ‘ 보μ΄λ λ¨μ (
px
) - μλ λ¨μ : λΆλͺ¨ μμ λλ μΉ λΈλΌμ°μ μ μ°½ ν¬κΈ°μ λ°λΌ μλμ μΌλ‘ κ²°μ λλ λ¨μ(λ°μν)
βμλ λ¨μ
%
λΆλͺ¨ μμμ μμ±κ°μ λν μλμ μΈ ν¬κΈ°
.parent {
font-size: 16px;
}
.child {
font-size: 80%;
}
.child-to-child {
font-size: 80%;
}
<!DOCTYPE html>
<html lang="ko">
<head>
<link rel="stylesheet" href="/css/λ¨μ.css">
</head>
<body>
<div class="parent">
<p>λΆλͺ¨μ ν°νΈ ν¬κΈ° μ
λλ€.</p>
<div class="child">
<p>μμμ ν°νΈ ν¬κΈ° μ
λλ€. </p>
<div class="child-to-child"></div>
</div>
</div>
</body>
</html>
em
λΆλͺ¨ μμμ ν μ€νΈ ν¬κΈ°λ₯Ό κΈ°μ€μΌλ‘ μλμ μΈ ν¬κΈ°
.parent {
font-size: 16px;
}
.child {
font-size: 2em; /* 16px λΆλͺ¨ ν¬κΈ°μ 2λ°°*/
}
.child-to-child {
font-size: 2em;
}
<!DOCTYPE html>
<html lang="ko">
<head>
<link rel="stylesheet" href="/css/λ¨μ.css">
</head>
<body>
<div class="parent">
<p>λΆλͺ¨μ ν°νΈ ν¬κΈ° μ
λλ€.</p>
<div class="child">
<p>μμμ ν°νΈ ν¬κΈ° μ
λλ€. </p>
<div class="child-to-child">
<p>μμμ μμ ν°νΈ ν¬κΈ° μ
λλ€.</p>
</div>
</div>
</div>
</body>
</html>
rem
html νκ·Έμ ν μ€νΈ ν¬κΈ°μ λν μλμ μΈ ν¬
html {
font-size: 1rem;
}
.parent {
font-size: 2rem;
}
.child {
font-size: 2rem;
}
<!DOCTYPE html>
<html lang="ko">
<head>
<link rel="stylesheet" href="/css/λ¨μ2.css">
</head>
<body>
<div class="parent">
<p>λΆλͺ¨μ ν°νΈ ν¬κΈ° μ
λλ€.</p>
<div class="child">
<p>μμμ ν°νΈ ν¬κΈ° μ
λλ€. </p>
</div>
</div>
</body>
</html>
vw, vh
vw λ¨μλ λ·°ν¬νΈ λλΉλ₯Ό κΈ°μ€μΌλ‘ μλμ μΈ ν¬κΈ°
1vw : λ·°ν¬νΈ λλΉμ 1/100 ν¬κΈ°λ₯Ό μλ―Έ, λ·°ν¬νΈμ κΈ°λ³Έ λλΉλ 900px
1vh : λ·°ν¬νΈ λμ΄μ 1/100 ν¬κΈ°λ₯Ό μλ―Έ, λ·°ν¬νΈμ κΈ°λ³Έ λμ΄λ 400px
.parent {
font-size: 1vw;
}
.child {
font-size: 2vw;
}
.child-to-child {
font-size: 3vw;
}
<!DOCTYPE html>
<html lang="ko">
<head>
<link rel="stylesheet" href="/css/λ¨μ.css">
</head>
<body>
<div class="parent">
<p>λΆλͺ¨μ ν°νΈ ν¬κΈ° μ
λλ€.</p>
<div class="child">
<p>μμμ ν°νΈ ν¬κΈ° μ
λλ€. </p>
<div class="child-to-child">
<p>μμμ μμ ν°νΈ ν¬κΈ° μ
λλ€. </p>
</div>
</div>
</div>
</body>
</html>
μμλλ©΄ μ’μ μμ!
νHDλ‘ ννν μ μλ μμμ μλ? 1920(w) * 1080(h) * 3byte
ν μ€νΈ μμ±
font-family μμ±
π μμ±κ°μΌλ‘ κΈκΌ΄λͺ μ μ κ³ , μ½€λ§(,)λ‘ κ΅¬λΆνκ³ 1κ° μ΄μμ κΈκΌ΄μ λμ΄ν΄ μ§μ ν©λλ€.
νκΈλ‘ λ κΈκΌ΄μ΄λ κ³΅λ°±μ΄ μλ κΈκΌ΄λͺ μ ν° λ°μ΄νλ‘ κ°μΈ νμν©λλ€.
body {
font-family: "λ§μ κ³ λ", "Nanum Gothic", sans-serif;
}
- serif : μμΉ¨μ΄ μλ λͺ μ‘° κ³μ΄
- sans-serif : μμΉ¨μ΄ μκ³ κ΅΅κΈ°κ° μΌμ ν κ³ λ κ³μ΄
- monospace : ν μ€νΈ νκ³Ό κ°κ²©μ΄ μΌμ
- fantasy : νλ €ν¨
- cursive : μμΌλ‘ μ΄ ν기체 κ³μ΄
font-size
π ν μ€νΈ ν¬κΈ° λ³κ²½, μΌλ°μ μΌλ‘ ν μ€νΈ ν¬κΈ°λ 16px
font-weight
π ν μ€νΈ κ΅΅κΈ° μ§μ
μ«μ νκΈ°λ²
π 100~ 900 κΉμ§ μ§μ κ°λ₯ (100μ μ΅μ κ΅΅κΈ°, 400μ κΈ°λ³Έ, 900μ μ΅λ κ΅΅κΈ°)
ν€μλ νκΈ°λ²
- normal : μ«μ νκΈ°λ²μμ 400κ³Ό κ°μ κ΅΅κΈ°
- bold : 700κ³Ό κ°μ κ΅΅κΈ°
- lighter : λΆλͺ¨ μμ λ³΄λ€ μκ² μ§μ λλ μλμ μΈ κ°
- bolder : λΆλͺ¨ μμ λ³΄λ€ κ΅΅κ² μ§μ λλ μλμ μΈ κ°
font-style μμ±
π κΈκΌ΄ μ€νμΌ μ§μ
- normal
- italic
- oblique
italicκ³Ό obliqueλ μ°¨μ΄κ° κ±°μ μμ§λ§..
italicμ λ³κ°μ κΈμ¨μ²΄κ³ , obliqueλ italicμ΄ μμ κ²½μ°μ normalμ κΈ°μΈμΈ κ²
font-variant μμ±
π μλ¬Έ ν μ€νΈλ₯Ό ν¬κΈ°κ° μμ λλ¬Έμλ‘ λ³κ²½
- normal
- small-caps : ν μ€νΈλ₯Ό ν¬κΈ°κ° μμ λλ¬Έμλ‘ λ³ν
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>font-variant</title>
<style>
.variant {
font-variant: small-caps;
}
</style>
</head>
<body>
<p>Lorem ipsum dolor sit.</p>
<p class="variant">Lorem ipsum dolor sit.</p>
</body>
</html>
text-align μμ±
π ν μ€νΈ μ λ ¬
- left : μΌμͺ½ μ λ ¬
- right : μ€λ₯Έμͺ½ μ λ ¬
- center : κ°μ΄λ° μ λ ¬
- justify : μμͺ½ μ λ ¬
μΈλΌμΈμΌλ‘ ν κ²½μ°μλ μ λ ¬ μ μ© μ λ¨!!!(span
...)
text-decoration μμ±
π ν μ€νΈλ₯Ό κΎΈλ©°μ£ΌκΈ° μν΄ μ¬μ© (μ μΌλ‘ νμ)
- none : μ₯μ μ κ±°
- line-through : μ·¨μμ
- overline : μμ€
- underline : λ°μ€
letter-spacing μμ±
π μκ° μ‘°μ ..μκ°μ κΈμ μ¬μ΄ κ°κ²©
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>letter-spacing</title>
<style>
p{
letter-spacing:15px;
}
</style>
</head>
<body>
<p>ν볡μ ν μͺ½ λ¬Έμ΄ λ«νλ©΄ λ€λ₯Έ μͺ½ λ¬Έμ΄ μ΄λ¦°λ€.
κ·Έλ¬λ νν μ°λ¦¬λ λ«νμ§ λ¬Έμ μ€λ«λμ 보기 λλ¬Έμ μ°λ¦¬λ₯Ό μν΄
μ΄λ € μλ λ¬Έμ λ³΄μ§ λͺ»νλ€.</p>
</body>
</html>
line-height μμ±
π ν μ€νΈ ν μ€μ λμ΄ μ§μ
p {
line-height: 1.5;
line-height: 200%;
line-height: 16px;
}
text-shadow μμ±
π κ·Έλ¦Όμ ν¨κ³Ό
text-shadow: κ°λ‘거리 μΈλ‘거리 λ²μ§μ λ μμ;
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>text-shadow</title>
<style>
h1 {
font-size:60px;
}
.shadow1 {
color:red;
text-shadow:1px 1px black;
}
.shadow2 {
text-shadow:5px 5px 3px #ffa500;
}
.shadow3 {
color:#fff;
text-shadow:7px -7px 20px #000;
}
</style>
</head>
<body>
<h1 class="shadow1">HTML</h1>
<h1 class="shadow2">CSS</h1>
<h1 class="shadow3">μλ°μ€ν¬λ¦½νΈ</h1>
</body>
</html>
λ°μ€ λͺ¨λΈ ꡬμ±
- margin : μμμ μΈλΆ μ¬λ°±
- border : μμμ ν λ리(κ²½κ³μ )
- padding : μμμ μμͺ½ μ¬λ°±
- content : μμμ λ΄μ©
margin
μμ μ£Όμμ 곡κ°.. λ§μ§μ μμμ μμ μ¬μ΄μλ μ μ©λ μ μμΌλ©°, λ€λ₯Έ μμμμ κ°κ²©μ μ‘°μ νλ λ° μ¬μ©ν©λλ€.
μ λ ₯ κ°―μμ λ°λ₯Έ κ·μΉ!!
- 4κ°λ₯Ό μ μΌλ©΄ μκ³ λ°©ν₯ μ(top, right, bottom, left)
- 3κ°λ₯Ό μ μΌλ©΄ top, right, bottomμ΄κ³ , μλ΅λ leftλ rightμ κ°μ κ°
- 2κ°λ₯Ό μ μΌλ©΄ top, bottom κ·Έλ¦¬κ³ left, rightκ° λ¬Άμ
- 1κ° μ μΌλ©΄ λͺ¨λ λ°©ν₯ μ μ©
border
marginλ³΄λ€ μμͺ½μ μμΌλ©°, μμμ ν λ리(κ²½κ³μ )λ₯Ό λ΄λΉ
border:[border κ°λ‘] [border style] [μμ];
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>border</title>
<style>
h1{
border:1px solid #f00;
}
h2{
border-bottom:2px dotted black;
}
</style>
</head>
<body>
<h1>h1</h1>
<h2>h2</h2>
</body>
</html>
border-style μμ±
π ν λ리μ λͺ¨μ
- none : ν λ리 x
- hidden : νλ©΄μμ κ°μΆ€
- solid : μ€μ
- double : μ΄μ€ μ€μ
- dotted : μ μ
- dashed : dotted λ³΄λ€ κΈ΄ μ μ
- groove : νμΈ κ² κ°μ
- ridge : νμ΄λμ¨ κ² κ°μ
- inset : ν λ리λ₯Ό μμκ° νμΈ κ² μ²λΌ
- outset : ν λ리λ₯Ό μμκ° νμ΄λμ¨ κ² μ²λΌ
padding μμ
margin, border μμλ³΄λ€ μμͺ½μ μμΌλ©°, μμμ λ΄λΆ μμ λ΄
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>padding</title>
<style>
p{
border:1px solid black;
padding:10px;
}
</style>
</head>
<body>
<p>padding</p>
</body>
</html>
box-sizing μμ±
π ν λ리 μμμ ν¬κΈ° κ²°μ
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>Box Model</title>
<style>
p {
border: 2px dashed red;
width: 100px;
height: 100px;
padding: 10px;
border: 1px solid black;
margin: 10px;
}
</style>
</head>
<body>
<p>νκ·Έ λ΄μ© νμΈ</p>
</body>
</html>
- content-box : μ§μ ν CSS width λ° heightλ₯Ό 컨ν μΈ μμμλ§ μ μ©, border, padding, marginμ λ°λ‘ κ³μ°λμ΄ μ 체 μμμ΄ μ€μ κ°λ³΄λ€ μ»€μ§ μ μμ
- border-box : μ§μ ν CSS width λ° heightλ₯Ό μ 체 μμμ μ μ©, border, padding, marginμ λͺ¨λ ν©μ°νκΈ° λλ¬Έμ 컨ν μΈ μμμ΄ μ€μ κ°λ³΄λ€ μμμ§ μ μμ
border-radius μμ±
μμμ ν λ리λ₯Ό λ₯κΈκ² λ§λ€μ΄μ€. pxλ¨μμ %λ¨μ μ¬μ©
λ°μ€ λͺ¨λΈμ μ±κ²©κ³Ό display μμ±
- λΈλ‘ μ±κ²©
π p, div νκ·Έλ₯Ό μ¬μ©νμ λ μμμ λλΉκ° 컨ν μΈ μ 무μ μκ΄μμ΄ νμ κ°λ‘ νμ€μ λ€ μ°¨μ§νλ κ² - μΈλΌμΈ μ±κ²©
π a, span, stron νκ·Έ λ±μ μ¬μ©νμ λ μμμ λλΉλ₯Ό 컨ν μΈ ν¬κΈ° λ§νΌ'λ§' μ°¨μ§νλ μ±κ²© - display μμ±
π HTML νκ·Έκ° κΈ°λ³ΈμΌλ‘ κ°μ§κ³ μλ λ°μ€ λͺ¨λΈμ μ±κ²©μ display μμ±μ μ¬μ©νλ©΄ λ³κ²½ κ°λ₯
λΈλ‘ μ±κ²©μΈ νκ·Έλ₯Ό μΈλΌμΈ μ±κ²©μΌλ‘ λ°κΎΈκ³ μΆλ€λ©΄display:inline;
μΌλ‘ μ§μ νλ©΄ λ©λλ€.
λ°°κ²½ μμ±μΌλ‘ μμμ λ°°κ²½ μ€μ
background-color μμ±
background-color: μμ;
background-image μμ±
background-image:url('μ΄λ―Έμ§ κ²½λ‘');
background-repeat μμ±
background-size μμ±
- cover : μ΄λ―Έμ§ μ릴 μ μμ
- contain : μμ λ΄λΆμ κ³΅λ°±μ΄ μκΈΈ μ μμ
background-positon μμ±
π μ΄λ―Έμ§ μμΉ μ§μ
background-attachment μμ±
π μμμ μ½μ λ μ΄λ―Έμ§λ₯Ό μ€ν¬λ‘€ ν λ, μ΄λ―Έμ§μ μλ λ°©μ κ²°μ
- scroll : λ°°κ²½ μ΄λ―Έμ§κ° μμμ ν¨κ» μ€ν¬λ‘€
- fixed : λ°°κ²½ μ΄λ―Έμ§κ° νλ©΄μ κ³ μ , μμμ ν¨κ» μ€ν¬λ‘€ λμ§ μμ
- local : λ°°κ²½ μ΄λ―Έμ§κ° μμμ ν¨κ» μ€ν¬λ‘€ λμ§λ§, μμμ λ΄λΆ μ½ν μΈ μλ λ 립μ μΌλ‘ μ€ν¬
'π¨ Frontend > HTML & CSS' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
CSS β β’ νμ μμ± - (3) μ°μ΅ λ¬Έμ (2) | 2023.03.15 |
---|---|
CSS β β’ νμ μμ± - (2) νλ©΄ λ°°μΉ (1) | 2023.03.15 |
CSS - β‘ μ νμ (0) | 2023.03.13 |
CSS - β κΈ°λ³Έ (0) | 2023.03.13 |
HTML - β’ μΉ λ¬Έμ ꡬ쑰λ₯Ό λ§λλ μλ§¨ν± νκ·Έ (0) | 2023.03.13 |