π
λͺ¨λ μΉμ μν HTML5+CSS3 λ°μ΄λΈ(4)
July 23, 2022
π λ€μ΄κ°κΈ°μ μμ
μ΄ κΈμ λͺ¨λ μΉμ μν HTML5+CSS3 λ°μ΄λΈ
μ 곡λΆνλ©° κΈ°μ΅ν΄λ λ΄μ©λ€μ κ°λ¨νκ² κΈ°λ‘ν κΈμ
λλ€.
μ±
μ λν μμΈν μ¬νμ λ§ν¬λ₯Ό μ°Έκ³ ν΄μ£ΌμΈμ. π
π 1. μΉ νμ΄μ§ λ μ΄μμ
λ μ΄μμ κ΄λ ¨ μ±ν°μ κ²½μ° μ½λλ₯Ό μ λμ΄νκ³ μ£ΌμμΌλ‘ λμλλ νλ€(πλ‘ νμν΄λκ² μ΅λλ€.)μ κΈ°λ‘νλ € ν©λλ€.
μ½λ μλ³Έμ λ§ν¬μμ λ°μΌμ€ μ μμ΅λλ€.
<!DOCTYPE html>
<html>
<head>
<title>Chapter_5</title>
<!-- π μ΄κΈ°ν : νμλ μλμ§λ§, λ³΄ν΅ μ 체 μ νμ(*)λ₯Ό ν΅ν΄ μλμ κ°μ κ°μΌλ‘ μ΄κΈ°ν ν μ€νμΌλ§μ μ§νν©λλ€. -->
<style>
* {
margin: 0;
padding: 0;
}
body {
font-family: 'Times New Roman', serif;
}
li {
list-style: none;
}
a {
text-decoration: none;
}
img {
border: 0;
}
</style>
<!-- ν€λ -->
<style>
#main_header {
/* π μ€μ μ λ ¬ : λ€μκ³Ό κ°μ λ°©λ²μΌλ‘ μμ£Ό μ€μ μ λ ¬ν΄μ€λλ€.*/
width: 960px;
margin: 0 auto;
/* π μ λ μ’ν : μλ μμ νκ·Έμ absoluteλ₯Ό μ μ©νκΈ°μ λΆλͺ¨ νκ·Έμ relativeλ₯Ό μ μ©ν©λλ€.
λν κ³΅κ° ν보λ₯Ό μν΄ heightκ°μ μ§μ ν΄μ€λλ€. */
height: 160px;
position: relative;
}
#main_header > #title {
position: absolute;
left: 20px;
top: 30px;
}
#main_header > #main_gnb {
position: absolute;
right: 0;
top: 0;
}
#main_header > #main_lnb {
position: absolute;
right: 0;
bottom: 10px;
}
</style>
<!-- νμ΄ν -->
<style>
#title {
font-family: 'Coiny', cursive;
}
</style>
<!-- λ©λ΄(1) -->
<style>
/* π li νκ·Έλ€μ μνμΌλ‘ λ§λ€κΈ° μν΄ float: leftλ₯Ό μ μ©νκ³ κ·Έ λΆλͺ¨ νκ·Έμ overflow: hidden μ²λ¦¬λ₯Ό ν΄μ€λλ€. */
#main_gnb > ul {
overflow: hidden;
}
#main_gnb > ul > li {
float: left;
}
#main_gnb > ul > li > a {
display: block;
padding: 2px 10px;
border: 1px solid black;
}
#main_gnb > ul > li > a:hover {
background: black;
color: white;
}
#main_gnb > ul > li:first-child > a {
border-radius: 10px 0 0 10px;
}
#main_gnb > ul > li:last-child > a {
border-radius: 0 10px 10px 0;
}
</style>
<!-- λ©λ΄(2) -->
<style>
#main_lnb > ul {
overflow: hidden;
}
#main_lnb > ul > li {
float: left;
}
#main_lnb > ul > li > a {
display: block;
padding: 10px 20px;
border: 1px solid black;
}
#main_lnb > ul > li > a:hover {
background: black;
color: white;
}
#main_lnb > ul > li:first-child > a {
border-radius: 10px 0 0 10px;
}
#main_lnb > ul > li:last-child > a {
border-radius: 0 10px 10px 0;
}
</style>
<!-- μ½ν
μΈ -->
<style>
#content {
/* μ€μ μ λ ¬ */
width: 960px;
margin: 0 auto;
/* π μν λ μ΄μμ ꡬμ±: μμ νκ·Έμ floatμ μ μ©νκ² λλ©΄ μ΄ λλΉ(960px)μμ κ°κ°μ λλΉ(750px, 200px)μ ν©μ λν΄μ 10pxμ΄ λ¨κ² λ©λλ€.
μ΄ 10pxμ κ°κ²©μΌλ‘ λκ³ #main_sectionκ³Ό #main_asideμ 곡κ°μ΄ λΆλ¦¬λ©λλ€.(μ¦, μμμ λλΉλ₯Ό μ§μ ν΄μ£Όλ©΄ μμμ λ¨μ κ°μΌλ‘ κ°κ²©μ΄ μκΉλλ€.) */
overflow: hidden;
}
#content > #main_section {
width: 750px;
float: left;
}
#content > #main_aside {
width: 200px;
float: right;
}
</style>
<!-- λ³Έλ¬Έ -->
<style>
#main_section > article.main_article {
margin-bottom: 10px;
padding: 20px;
border: 1px solid black;
}
</style>
<!-- μ¬μ΄λ -->
<style>
/* π 첫 λ²μ§Έ ν: inputμ check μμ΄μ½ μ체λ μ¨κΉλλ€. inputμ΄ μ²΄ν¬λμ§ μμμ λλ μ보μ΄κ² νκ³ , 체ν¬κ° λλ©΄ 보μ΄κ² ν©λλ€. */
input:nth-of-type(1) {
display: none;
}
input:nth-of-type(1) ~ div:nth-of-type(1) {
display: none;
}
input:nth-of-type(1):checked ~ div:nth-of-type(1) {
display: block;
}
/* π λ λ²μ§Έ ν: 첫 λ°΄μ§Έ ν
κ³Ό λ§μ°¬κ°μ§μ
λλ€. */
input:nth-of-type(2) {
display: none;
}
input:nth-of-type(2) ~ div:nth-of-type(2) {
display: none;
}
input:nth-of-type(2):checked ~ div:nth-of-type(2) {
display: block;
}
/* ν λͺ¨μ κ΅¬μ± */
section.buttons {
overflow: hidden;
}
section.buttons > label {
/* μν μ λ ¬ */
display: block;
float: left;
/* ν¬κΈ° λ° κΈμ μμΉ μ§μ */
width: 100px;
height: 30px;
line-height: 30px;
text-align: center;
/* ν
λ리 μ§μ */
box-sizing: border-box;
border: 1px solid black;
/* μμ μ§μ */
background: black;
color: white;
}
input:nth-of-type(1):checked ~ section.buttons > label:nth-of-type(1) {
background: white;
color: black;
}
input:nth-of-type(2):checked ~ section.buttons > label:nth-of-type(2) {
background: white;
color: black;
}
</style>
<!-- λͺ©λ‘ -->
<style>
.item {
overflow: hidden;
padding: 10px;
border: 1px solid black;
border-top: none;
}
.thumbnail {
float: left;
}
.description {
float: left;
margin-left: 10px;
}
.description > strong {
display: block;
width: 120px;
white-space: nowrap; /* π λ°μ€ λ΄μ κΈμκ° λ κΈΈμ΄μ ννκ° κΉ¨μ§ λ μ¬μ©ν©λλ€. */
overflow: hidden; /* π μ¬μ©νκ² λλ©΄ 'jayden is good!'κ³Ό κ°μ κΈμκ° 'jayden is...' λ‘ λ°μ€ ν¬κΈ°μ λ§κ² μλ΅λ©λλ€. */
text-overflow: ellipsis; /* π μ΄ 3κ°μ§ μμ±μ΄ ν¨κ» μ μ©λλ―λ‘ ν΅μ§Έλ‘ μΈμ§νκ³ μ°Ύμμ 볡λΆνμ¬ μ¬μ©νλ κ² μ’μ΅λλ€. βοΈ */
}
</style>
<!-- νΈν° -->
<style>
#main_footer {
/* μ€μ μ λ ¬ */
width: 960px;
margin: 0 auto;
margin-bottom: 10px;
/* ν
λ리 */
box-sizing: border-box;
padding: 10px;
border: 1px solid black;
/* κΈμ μ λ ¬ */
text-align: center;
}
</style>
</head>
<body>
<header id="main_header">
<div id="title">
<h1>Rint Development</h1>
<h2>HTML5 + CSS3 Basic</h2>
</div>
<nav id="main_gnb">
<ul>
<li><a href="#">Web</a></li>
<li><a href="#">Mobile</a></li>
<li><a href="#">Game</a></li>
<li><a href="#">Simulation</a></li>
<li><a href="#">Data</a></li>
</ul>
</nav>
<nav id="main_lnb">
<ul>
<li><a href="#">HTML5</a></li>
<li><a href="#">CSS3</a></li>
<li><a href="#">JavaScript</a></li>
<li><a href="#">jQuery</a></li>
<li><a href="#">Node.js</a></li>
</ul>
</nav>
</header>
<div id="content">
<section id="main_section">
<article class="main_article">
<h1>Main Article</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur in magna libero. Sed
nec pharetra nunc. Proin eget magna id ipsum eleifend cursus sit amet nec lectus. Nunc
quis lacus magna. Aliquam blandit, sapien ut viverra fermentum, elit tortor ornare nisi,
in luctus sem massa pulvinar turpis. Cras tincidunt dictum urna ut ultricies. Nullam
diam nibh, pellentesque non laoreet ut, bibendum nec mauris. Maecenas pulvinar porttitor
laoreet. Vivamus bibendum purus nisl, eget aliquam lectus. Maecenas justo libero,
euismod sit amet suscipit eu, vulputate eget neque. Aliquam quam est, blandit nec
iaculis non, suscipit vel nunc. Proin et odio aliquam erat pharetra accumsan et quis
neque. Vivamus interdum accumsan leo eu adipiscing. Integer accumsan elit non turpis
faucibus porttitor. Aliquam scelerisque nisi et turpis pretium at ultricies turpis
pharetra.
</p>
</article>
<article class="main_article">
<h1>Main Article</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur in magna libero. Sed
nec pharetra nunc. Proin eget magna id ipsum eleifend cursus sit amet nec lectus. Nunc
quis lacus magna. Aliquam blandit, sapien ut viverra fermentum, elit tortor ornare nisi,
in luctus sem massa pulvinar turpis. Cras tincidunt dictum urna ut ultricies. Nullam
diam nibh, pellentesque non laoreet ut, bibendum nec mauris. Maecenas pulvinar porttitor
laoreet. Vivamus bibendum purus nisl, eget aliquam lectus. Maecenas justo libero,
euismod sit amet suscipit eu, vulputate eget neque. Aliquam quam est, blandit nec
iaculis non, suscipit vel nunc. Proin et odio aliquam erat pharetra accumsan et quis
neque. Vivamus interdum accumsan leo eu adipiscing. Integer accumsan elit non turpis
faucibus porttitor. Aliquam scelerisque nisi et turpis pretium at ultricies turpis
pharetra.
</p>
</article>
<article class="main_article">
<h1>Main Article</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur in magna libero. Sed
nec pharetra nunc. Proin eget magna id ipsum eleifend cursus sit amet nec lectus. Nunc
quis lacus magna. Aliquam blandit, sapien ut viverra fermentum, elit tortor ornare nisi,
in luctus sem massa pulvinar turpis. Cras tincidunt dictum urna ut ultricies. Nullam
diam nibh, pellentesque non laoreet ut, bibendum nec mauris. Maecenas pulvinar porttitor
laoreet. Vivamus bibendum purus nisl, eget aliquam lectus. Maecenas justo libero,
euismod sit amet suscipit eu, vulputate eget neque. Aliquam quam est, blandit nec
iaculis non, suscipit vel nunc. Proin et odio aliquam erat pharetra accumsan et quis
neque. Vivamus interdum accumsan leo eu adipiscing. Integer accumsan elit non turpis
faucibus porttitor. Aliquam scelerisque nisi et turpis pretium at ultricies turpis
pharetra.
</p>
</article>
</section>
<aside id="main_aside">
<input id="first" type="radio" name="tab" checked="checked" />
<input id="second" type="radio" name="tab" />
<section class="buttons">
<label for="first">First</label>
<label for="second">Second</label>
</section>
<div class="tab_item">
<ul>
<li class="item">
<a href="#">
<div class="thumbnail">
<img src="http://placehold.it/45x45" />
</div>
<div class="description">
<strong>HTML5 Canvas</strong>
<p>2012-03-15</p>
</div>
</a>
</li>
<li class="item">
<a href="#">
<div class="thumbnail">
<img src="http://placehold.it/45x45" />
</div>
<div class="description">
<strong>HTML5 Audio</strong>
<p>2012-03-15</p>
</div>
</a>
</li>
<li class="item">
<a href="#">
<div class="thumbnail">
<img src="http://placehold.it/45x45" />
</div>
<div class="description">
<strong>HTML5 Video</strong>
<p>2012-03-15</p>
</div>
</a>
</li>
<li class="item">
<a href="#">
<div class="thumbnail">
<img src="http://placehold.it/45x45" />
</div>
<div class="description">
<strong>HTML5 Semantic Web</strong>
<p>2012-03-15</p>
</div>
</a>
</li>
</ul>
</div>
<div class="tab_item">
<ul>
<li class="item">
<a href="#">
<div class="thumbnail">
<img src="http://placehold.it/45x45" />
</div>
<div class="description">
<strong>CSS3 Transition</strong>
<p>2012-03-15</p>
</div>
</a>
</li>
<li class="item">
<a href="#">
<div class="thumbnail">
<img src="http://placehold.it/45x45" />
</div>
<div class="description">
<strong>CSS3 Animation</strong>
<p>2012-03-15</p>
</div>
</a>
</li>
<li class="item">
<a href="#">
<div class="thumbnail">
<img src="http://placehold.it/45x45" />
</div>
<div class="description">
<strong>CSS3 Border</strong>
<p>2012-03-15</p>
</div>
</a>
</li>
<li class="item">
<a href="#">
<div class="thumbnail">
<img src="http://placehold.it/45x45" />
</div>
<div class="description">
<strong>CSS3 Box</strong>
<p>2012-03-15</p>
</div>
</a>
</li>
</ul>
</div>
</aside>
</div>
<footer id="main_footer">
<h3>HTML5 + CSS3 Basic</h3>
<address>Website Layout Basic</address>
</footer>
</body>
</html>
π μ 리
μ€μν λ΄μ©
- λ μ΄μμμ
ν
λ¨μλ‘ μκ°νκΈ° - λ μ΄μμ μ΄κΈ°ν μ½λ
- widthμ marginμ μ¬μ©νμ¬ μ€μ μ λ ¬νκΈ°
- absoluteμ relative μ¬μ© κ·Έλ¦¬κ³ heightλ₯Ό ν΅ν μμ ν보
- overflowμ floatμ μ¬μ©ν΄μ λ μ΄μμ λλλ λ°©λ²