๋ด์ฉ ์์ฝ
CSS(Cascading Style Sheets) : HTML, XML๊ฐ์ ๋งํฌ์ ์ธ์ด ๋ฌธ์์ ์คํ์ผ์ ๊พธ๋ฏธ๊ธฐ ์ํ ์คํ์ผ ์ํธ ์ธ์ด
CSS ์์ฑ ํ์ต ์ฌ์ดํธ : w3schools
- css ์ ์ํ๊ธฐ
1. ์ธ๋ผ์ธ ์คํ์ผ : <style> ์์ ๋ด๋ถ์ css ์์ฑ์ ์ง์ ์ ๋ ฅํ๋ ๋ฐฉ์
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS ์ด๋ก ํ์ต</title>
<style>
body {
margin : 0;
padding : 20px;
font-family: Arial, sans-serif;
}
h1 {
background-color : black;
color : #fff;
}
h1, h2 {
text-align: center;
}
a {
text-decoration: none;
color:unset;
}
</style>
</head>
2. ์ธ๋ถ css ํ์ผ (๊ถ์ฅ) : <link> ์์์ href ์์ฑ์ผ๋ก css ํ์ผ๋ช ์ ์ ๋ ฅํ๋ ๋ฐฉ์
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS ์ด๋ก ํ์ต</title>
<!-- rel ์์ฑ์ ํ์ฌ ๋ฌธ์์ ์ธ๋ถ ๋ฆฌ์์ค ์ฌ์ด์ ์ฐ๊ด ๊ด๊ณ๋ฅผ ์๋ฏธ -->
<!-- href ์์ฑ์ ๋งํฌ -->
<link rel="stylesheet" href="style.css">
</head>
style.css
@charset "UTF-8";
body {
margin : 0;
padding : 20px;
font-family: Arial, sans-serif;
}
h1 {
background-color : black;
color : #fff;
}
h1, h2 {
text-align: center;
}
a {
text-decoration: none;
color:unset;
}
- ์ ํ์
css๋ html ์์๋ฅผ ์ ํํ๊ธฐ ์ํด ์ ํ์๋ฅผ ์ฌ์ฉํ๋ค.
body {
margin : 0; /* ํ
๋๋ฆฌ ๋ฐ ์ฌ๋ฐฑ ํฌ๊ธฐ ์ค์ */
padding : 20px; /* ํ
๋๋ฆฌ ์ ์ฌ๋ฐฑ ํฌ๊ธฐ ์ค์ */
font-family : Arial, sans-serif; /* ํฐํธ ์ข
๋ฅ ์ค์ */
}
h1 {
background-color : black; /* h1 ํ๊ทธ ์์ญ์ ๋ฐฐ๊ฒฝ ์ ์ค์ */
color : #fff; /* ๊ธ์ ์ ์ค์ */
}
h1, h2 {
text-align : center; /* ํ
์คํธ์ ์ ๋ ฌ ์ค์ (์ค์) */
}
a {
text-decoration : none; /* ํ
์คํธ๋ฅผ ๊พธ๋ฏธ๋ ์์(๋ฐ์ค ๋ฑ) ์ค์ */
color : unset;
}
์คํ์ผ์ ์ง์ ํ๊ธฐ ์ํด์๋ ๋ค์๊ณผ ๊ฐ์ด ์์ฑ๊ณผ ๊ฐ์ ์์ ์ฌ์ฉํ๋ค.
ex) background-color ์์ฑ - black ๊ฐ
body๋ <body> ์์, h1๋ <h1>์์, a๋ <a>์์, h1, h2์ ๊ฒฝ์ฐ์๋ <h1>์์์ <h2>์์ ๋ ๋ชจ๋ ์ ํํ ์ ์๋ค.
์ด ์ธ์๋ id, class ์ ํ์๋ก ๊ฐ๊ฐ์ ์คํ์ผ์ ์ง์ ํ ์ ์๋ค.
1. class ์ ํ์
์ฌ๋ฌ ์์๋ฅผ ๊ทธ๋ฃนํํ๊ณ , ํด๋น ๊ทธ๋ฃน์ ์คํ์ผ์ ์ ์ฉํ๋ค.
ํ๋์ ์์๊ฐ ์ฌ๋ฌ ํด๋์ค๋ฅผ ๊ฐ์ง ์ ์๊ณ , ์ฌ๋ฌ ์์๊ฐ ๋์ผํ ํด๋์ค๋ฅผ ๊ฐ์ง ์ ์๋ค.
beginner.html
<ul class="highlight paragraph">
<li>a. HTML ์์ตํ๊ธฐ</li>
<li>b. MDN ์ฌ์ดํธ ์ ์ํ๊ธฐ</li>
<li>c. w3school ์ฌ์ดํธ ์ ์ํ๊ธฐ</li>
<li>d. ์ค์ต ๋์ ํ๊ธฐ</li>
</ul>
<h2 class="highlight">๊ธ์จ ๊ฐ์กฐํ๊ธฐ</h2>
<p><i>HTML</i> ์์ตํ๊ธฐ</p>
<p><b>MDN</b> ์ฌ์ดํธ ์ ์ํ๊ธฐ</p>
<p><u>w3school</u> ์ฌ์ดํธ ์ ์ํ๊ธฐ</p>
<p><em>์ค์ต</em>๋์ ํ๊ธฐ</p>
style.css
.highlight {
background-color: yellow;
}
.paragraph {
font-size : 12px;
}
2. id ์ ํ์
id ์ ํ์๋ ์ ์ผ์ฑ์ ๋ณด์ฅํ๊ธฐ ์ํด ์ฌ์ฉํ๋ค.
๋๋ฌธ์ html ๋ฌธ์ ์ ์ฒด์์ ๋์ผํ id๋ฅผ ๊ฐ์ง๋ ์์๊ฐ ๋ ๊ฐ ์ด์ ์์ผ๋ฉด ์๋๋ค.
<div id="header">
<div class="menu">์ค๋ ํ ์ผ</div>
<div class="menu">๋ด์ผ ํ ์ผ</div>
<div class="menu">๋ชจ๋ ํ ์ผ</div>
</div>
#header {
padding : 0;
margin : 0;
background-color: aquamarine;
display : flex;
justify-content: space-between;
}
#header .menu {
padding : 10px 15px;
list-style-type: none;
}
์ค์ต ๊ณผ์
@charset "UTF-8";
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
}
a {
text-decoration: none;
color: unset;
}
.daily-title {
color : #3498db;
}
.task {
font-size : 18px;
margin-bottom: 10px;
}
#challenge-task {
font-weight : bold;
}
'์ค์ฆ์ฝ๋ฉ์ค์ฟจ ํ๋ก ํธ์๋ 10๊ธฐ > ๋ฒ ์ด์ค์บ ํ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๋น๊ธฐ๋ ํธ๋ 9 - CSS ์ด๋ก (2) (0) | 2025.02.21 |
---|---|
์๋ฐ์ ์นผ๋ผ 3 - ์ํ ๋ฏน ํด๋น (0) | 2025.02.20 |
๋น๊ธฐ๋ ํธ๋ 7 - HTML ์ด๋ก (0) | 2025.02.15 |
๋น๊ธฐ๋ ํธ๋ 6 - Git๊ณผ GitHub (0) | 2025.02.14 |
๋น๊ธฐ๋ ํธ๋ 5 - CLI(Command Line Interface) (0) | 2025.02.13 |