์ ์ฉ ์ฐ์ ์์
!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 |