๐
๋ชจ๋ ์น์ ์ํ HTML5+CSS3 ๋ฐ์ด๋ธ(7)
July 24, 2022
๐ ๋ค์ด๊ฐ๊ธฐ์ ์์
์ด ๊ธ์ ๋ชจ๋ ์น์ ์ํ HTML5+CSS3 ๋ฐ์ด๋ธ
์ ๊ณต๋ถํ๋ฉฐ ๊ธฐ์ตํด๋ ๋ด์ฉ๋ค์ ๊ฐ๋จํ๊ฒ ๊ธฐ๋กํ ๊ธ์
๋๋ค.
์ฑ
์ ๋ํ ์์ธํ ์ฌํญ์ ๋งํฌ๋ฅผ ์ฐธ๊ณ ํด์ฃผ์ธ์. ๐
๐ 1. ์์ ์ปค๋จธ์ค ๋ฉ์ธ ํ์ด์ง
์ฝ๋๋ฅผ ์ญ ๋์ดํ๊ณ ์ฃผ์์ผ๋ก ๋์๋๋ ํ๋ค(๐๋ก ํ์ํด๋๊ฒ ์ต๋๋ค.)์ ๊ธฐ๋กํ๋ ค ํฉ๋๋ค. ์ฝ๋ ์๋ณธ์ ๋งํฌ์์ ๋ฐ์ผ์ค ์ ์์ต๋๋ค.
<!DOCTYPE html>
<html>
<head>
<title>Chapter 8</title>
<!-- ๊ตฌ ๋ฒ์ ์ ์ธํฐ๋ท ์ต์คํ๋ก๋ฌ์์ HTML5 ํ๊ทธ๋ฅผ ์ธ์ํ๊ฒ ํฉ๋๋ค. -->
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- ์ด๊ธฐํ -->
<style>
* {
margin: 0;
padding: 0;
font: normal 12px 'Dotum';
}
a {
text-decoration: none;
}
img {
border: 0;
}
ul {
list-style: none;
}
/* ๐ ์ค์์ ์์นํ๊ฒ ํฉ๋๋ค. */
body {
width: 980px;
margin: 0 auto;
}
</style>
<!-- ํค๋ -->
<style>
/* ๐ ์์ ํ๊ทธ์ position: absolute; ๋ผ๋ฉด ๋ถ๋ชจ ํ๊ทธ์ position: relative; ๋ฅผ ์ ์ฉํฉ๋๋ค. ๐ฏ */
#main_header {
position: relative;
height: 75px;
}
#main_header > h1.logo {
position: absolute;
left: 15px;
top: 10px;
}
#main_header > div.login_menu {
position: absolute;
top: 10px;
right: 0px;
}
</style>
<!-- ์ฌ์ด๋ -->
<style>
/* ๐ ์์ ํ๊ทธ์ position: absolute; ๋ผ๋ฉด ๋ถ๋ชจ ํ๊ทธ์ position: relative; ๋ฅผ ์ ์ฉํฉ๋๋ค. ๐ฏ */
body {
position: relative;
}
#global_aside {
position: absolute;
left: 990px;
top: 75px;
width: 90px;
}
#global_aside > a {
display: block;
margin-bottom: 5px;
}
</style>
<!-- ๋ค๋น๊ฒ์ด์
_์ -->
<style>
/* ๐ ์์ ํ๊ทธ์ float ์์ฑ์ ์ ์ฉํ๋ฉด ๋ถ๋ชจ ํ๊ทธ์ overflow: hidden; ์ ์ ์ฉํฉ๋๋ค. ๐ฏ */
#top_gnb {
overflow: hidden;
}
#top_gnb > div.menu {
float: left;
width: 140px;
height: 50px;
background: url('Images/top_gnb.png');
}
/* ๐ ์คํ๋ผ์ดํธ ์ด๋ฏธ์ง์์ ๊ฐ๊ฐ์ ์ด๋ฏธ์ง๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํด background-position์ ์ฌ์ฉํฉ๋๋ค.
2๊ฐ์ ์ธ์์ผ ๋, ์ฒซ ๋ฒ์งธ ๊ฐ์ด x ์ถ, ๋ ๋ฒ์งธ ๊ฐ์ด y ์ถ์
๋๋ค.
๋ง์น ํฌํ ์ต ๋ ์ด์ด์์ ๋ฐฐ๊ฒฝ ๋ ์ด์ด๋ฅผ ์์ง์ธ๋ค๊ณ ์๊ฐํ๋ฉด ํธํฉ๋๋ค. */
#top_gnb > div.item_1 {
background-position: 0px 0px;
}
#top_gnb > div.item_2 {
background-position: 0px -50px;
}
#top_gnb > div.item_3 {
background-position: 0px -100px;
}
#top_gnb > div.item_4 {
background-position: 0px -150px;
}
#top_gnb > div.item_5 {
background-position: 0px -200px;
}
#top_gnb > div.item_6 {
background-position: 0px -250px;
}
#top_gnb > div.item_7 {
background-position: 0px -300px;
}
#top_gnb > div.item_1:hover {
background-position: 0px -350px;
}
#top_gnb > div.item_2:hover {
background-position: 0px -400px;
}
#top_gnb > div.item_3:hover {
background-position: 0px -450px;
}
#top_gnb > div.item_4:hover {
background-position: 0px -500px;
}
#top_gnb > div.item_5:hover {
background-position: 0px -550px;
}
#top_gnb > div.item_6:hover {
background-position: 0px -600px;
}
#top_gnb > div.item_7:hover {
background-position: 0px -650px;
}
#top_gnb > div.item_1.active {
background-position: 0px -350px;
}
#top_gnb > div.item_2.active {
background-position: 0px -400px;
}
#top_gnb > div.item_3.active {
background-position: 0px -450px;
}
#top_gnb > div.item_4.active {
background-position: 0px -500px;
}
#top_gnb > div.item_5.active {
background-position: 0px -550px;
}
#top_gnb > div.item_6.active {
background-position: 0px -600px;
}
#top_gnb > div.item_7.active {
background-position: 0px -650px;
}
</style>
<!-- ๋ค๋น๊ฒ์ด์
_์๋ -->
<style>
#bottom_gnb {
overflow: hidden;
}
#bottom_gnb > div.menu {
float: left;
width: 98px;
height: 80px;
background: url('Images/bottom_gnb.png');
}
#bottom_gnb > div.item_1 {
background-position: 0px 0px;
}
#bottom_gnb > div.item_2 {
background-position: 0px -80px;
}
#bottom_gnb > div.item_3 {
background-position: 0px -160px;
}
#bottom_gnb > div.item_4 {
background-position: 0px -240px;
}
#bottom_gnb > div.item_5 {
background-position: 0px -320px;
}
#bottom_gnb > div.item_6 {
background-position: 0px -400px;
}
#bottom_gnb > div.item_7 {
background-position: 0px -480px;
}
#bottom_gnb > div.item_8 {
background-position: 0px -560px;
}
#bottom_gnb > div.item_9 {
background-position: 0px -640px;
}
#bottom_gnb > div.item_10 {
background-position: 0px -720px;
}
#bottom_gnb > div.item_1:hover {
background-position: 0px -800px;
}
#bottom_gnb > div.item_2:hover {
background-position: 0px -880px;
}
#bottom_gnb > div.item_3:hover {
background-position: 0px -960px;
}
#bottom_gnb > div.item_4:hover {
background-position: 0px -1040px;
}
#bottom_gnb > div.item_5:hover {
background-position: 0px -1120px;
}
#bottom_gnb > div.item_6:hover {
background-position: 0px -1200px;
}
#bottom_gnb > div.item_7:hover {
background-position: 0px -1280px;
}
#bottom_gnb > div.item_8:hover {
background-position: 0px -1360px;
}
#bottom_gnb > div.item_9:hover {
background-position: 0px -1440px;
}
#bottom_gnb > div.item_10:hover {
background-position: 0px -1520px;
}
#bottom_gnb > div.item_1.active {
background-position: 0px -800px;
}
#bottom_gnb > div.item_2.active {
background-position: 0px -880px;
}
#bottom_gnb > div.item_3.active {
background-position: 0px -960px;
}
#bottom_gnb > div.item_4.active {
background-position: 0px -1040px;
}
#bottom_gnb > div.item_5.active {
background-position: 0px -1120px;
}
#bottom_gnb > div.item_6.active {
background-position: 0px -1200px;
}
#bottom_gnb > div.item_7.active {
background-position: 0px -1280px;
}
#bottom_gnb > div.item_8.active {
background-position: 0px -1360px;
}
#bottom_gnb > div.item_9.active {
background-position: 0px -1440px;
}
#bottom_gnb > div.item_10.active {
background-position: 0px -1520px;
}
</style>
<!-- ๋ชฉ๋ก -->
<style>
/* ๐ ์์ ํ๊ทธ์ float ์์ฑ์ ์ ์ฉํ๋ฉด ๋ถ๋ชจ ํ๊ทธ์ overflow: hidden; ์ ์ ์ฉํฉ๋๋ค. ๐ฏ */
#detail_list {
overflow: hidden;
padding: 10px;
background: #3b414d;
padding-bottom: 15px;
}
#detail_list > ul {
float: left;
width: 192px;
}
#detail_list > ul > li {
height: 13px;
margin-top: 5px;
padding: 3px 5px;
color: #f3f3f3;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#detail_list > ul > li.header {
padding-left: 15px;
}
#detail_list > ul > li.header > p {
font-weight: bold;
color: #48c5ff;
}
</style>
<!-- ๋ณธ๋ฌธ -->
<style>
#content {
margin-top: 10px;
}
#product_section {
overflow: hidden;
margin-top: 5px;
}
#product_section > #product_article {
float: left;
width: 795px;
}
#product_section > #product_aside {
float: right;
padding-bottom: 5px;
width: 170px;
}
#product_section > #product_article > img {
display: block;
}
</style>
<!-- ํธํฐ -->
<style>
#main_footer {
height: 40px;
padding: 10px;
margin-bottom: 10px;
background: #9c9c9c;
border-radius: 5px;
text-align: center;
}
#main_footer > h1 {
font-size: 1.5em;
font-weight: bold;
}
#main_footer > h2 {
font-size: 1.2em;
font-weight: bold;
}
</style>
</head>
<body>
<header id="main_header">
<h1 class="logo">
<a href="#"><img src="Images/title.png" /></a>
</h1>
<div class="login_menu">
<span><a href="#">๋ก๊ทธ์ธ</a></span>
<span><a href="#">ํ์๊ฐ์
</a></span>
<span><a href="#">๊ณ ๊ฐ์ผํฐ</a></span>
</div>
</header>
<aside id="global_aside">
<a><img src="http://placehold.it/90x160" /></a>
<a><img src="http://placehold.it/90x160" /></a>
<a><img src="http://placehold.it/90x160" /></a>
<a><img src="http://placehold.it/90x160" /></a>
<a><img src="http://placehold.it/90x160" /></a>
<a><img src="http://placehold.it/90x160" /></a>
<a><img src="http://placehold.it/90x160" /></a>
<a><img src="http://placehold.it/90x160" /></a>
<a><img src="http://placehold.it/90x160" /></a>
<a><img src="http://placehold.it/90x160" /></a>
</aside>
<nav id="top_gnb">
<div class="menu item_1 active"></div>
<div class="menu item_2"></div>
<div class="menu item_3"></div>
<div class="menu item_4"></div>
<div class="menu item_5"></div>
<div class="menu item_6"></div>
<div class="menu item_7"></div>
</nav>
<nav id="bottom_gnb">
<div class="menu item_1"></div>
<div class="menu item_2"></div>
<div class="menu item_3"></div>
<div class="menu item_4"></div>
<div class="menu item_5"></div>
<div class="menu item_6"></div>
<div class="menu item_7"></div>
<div class="menu item_8"></div>
<div class="menu item_9 active"></div>
<div class="menu item_10"></div>
</nav>
<div id="detail_list">
<ul class="column_1">
<li class="header"><p>๊ฒ์์ฉ ๋
ธํธ๋ถ</p></li>
<li>์์ด์จ ๊ฒ์์ฉ ๋
ธํธ๋ถ</li>
<li>๋์๋ธ๋ก ๊ฒ์์ฉ ๋
ธํธ๋ถ</li>
<li>๋ธ์ ๊ฒ์์ฉ ๋
ธํธ๋ถ</li>
<li class="header"><p>์ธํธ๋ผ๋ถ</p></li>
<li>ํฌ๋กํคํฐ ์ธํธ๋ผ๋ถ</li>
<li>๋ฆฌ๋ฝ์ฟ ๋ง ์ธํธ๋ผ๋ถ ์ดํน๊ฐ</li>
<li>์นดํผ๋ฐ๋ผ ์ธํธ๋ผ๋ถ</li>
<li>์ตธํ ์ธํธ๋ผ๋ถ</li>
<li>๊ณ ์์ด ์ธํธ๋ผ๋ถ</li>
</ul>
<ul class="column_2">
<li>๋๋ฆฌ ์ธํธ๋ผ๋ถ</li>
<li class="header"><p>๋
ธํธ๋ถ ๊ฐ๋ฐฉ</p></li>
<li>์์ฌํ ๋ธ๋๋ ๋
ธํธ๋ถ ๊ฐ๋ฐฉ</li>
<li>๋ณด๋
ธ๋ณด๋
ธ ๊ฐ๋ฐฉ</li>
<li>๋์ฝค ๊ฐ๋ฐฉ</li>
<li class="header"><p>๋ฐ์นจ๋/์ฟจ๋ฌ</p></li>
<li>์์ด๋ฐ๋ค์ฆ ๋ฐ์นจ๋</li>
<li>๊น์จ ์ฟจ๋ฌ</li>
<li>ํค๋ผํด๋ ์ค ์ผ๊ฐ ๋ฐ์นจ๋</li>
<li>ํ๋ ์คํธ๋ผํ ์บ์คํฐ ์ฟจ๋ฌ</li>
</ul>
<ul class="column_3">
<li class="header"><p>๋
ธํธ๋ถ ๋ณดํธ ์ฉํ</p></li>
<li>Node.js ๋ฐฉ์ด ๋ณดํธํ</li>
<li>์๋๋ก์ด๋</li>
<li>์ดํน๊ฐ ์๋ฐ์คํฌ๋ฆฝํธ ๋ณดํธ๋</li>
<li>๊ธฐ๊ณ ํ์ต์ ์ฌ์ฉํ ๋ณดํธ๋</li>
<li class="header"><p>๋งฅ๋ถ</p></li>
<li>์๊ณ ๋ฅผ ์์ฑํ๋ ๋งฅ๋ถ ์์ด</li>
<li>๋ ํฐ๋ ๋์คํ๋ ์ด</li>
<li class="header"><p>๋
ธํธ๋ถ ๋ณดํธ ์ฉํ</p></li>
<li>๋ฌผ๊ฑด ์ด๋ฆ ๋ง๋ค๊ธฐ ํ๋ค์ด</li>
</ul>
<ul class="column_4">
<li>์ฐ์ฃผ ๋ฐฉ์ฌ๋ฅ ๋ณดํธ ์ฝํ
์ </li>
<li>์์ฒด ์ค๋ ฅ ์์ฑ ์ฅ์น</li>
<li>์ดํน๊ฐ</li>
<li>๋
ธํธ๋ถ ํฌ๋ช
ํ ์คํ๋ ์ด</li>
<li>๊ณ ์ ์ ๋ฅ</li>
<li class="header"><p>๋
ธํธ๋ถ ๋ณด์กฐ ์ฉํ</p></li>
<li>์ดํน๊ฐ</li>
<li>๊ณต๊ฐ ๊ท ์ด ์ฅ์น</li>
<li>ํ๋ก๊ทธ๋จ ๋ง๋๋ ํ๋ก๊ทธ๋จ</li>
<li>์ดํน๊ฐ</li>
</ul>
<ul class="column_5">
<li>๋ฏธ์ค ๋ฒ ์ด์ค ์ฅ์น</li>
<li>๊ณต๊ฐ์ ์ง๋ฐฐํ๋์</li>
<li>ํ๊ธ ํ ์ธ</li>
<li class="header"><p>์ธ์ฅ ํ๋ ๋์คํฌ</p></li>
<li>ํ ์๋ฐ 500GB ์ธ์ฅ ํ๋</li>
<li>์ด๊ณต๊ฐ ํตํฉ ๋ฌดํ ๋ฉ๋ชจ๋ฆฌ</li>
<li>๋ชจ๋ ์น์ ์ํ Node.js ํ๋ก๊ทธ๋๋ฐ</li>
<li>๋ชจ๋ ์น์ ์ํ JavaScript + jQuery ์
๋ฌธ</li>
<li>์ค์ธ์ฑ</li>
<li>์ด๋ฆ ๋ง๋ค๊ธฐ ํ๋ค์ด์</li>
</ul>
</div>
<div id="content">
<figure id="product_image">
<img src="http://placehold.it/980x440" />
</figure>
<section id="product_section">
<article id="product_article">
<img src="http://placehold.it/795x400" />
<img src="http://placehold.it/795x400" />
<img src="http://placehold.it/795x400" />
</article>
<aside id="product_aside">
<a href="#"><img src="http://placehold.it/170x200" /></a>
<a href="#"><img src="http://placehold.it/170x200" /></a>
<a href="#"><img src="http://placehold.it/170x200" /></a>
<a href="#"><img src="http://placehold.it/170x200" /></a>
<a href="#"><img src="http://placehold.it/170x200" /></a>
<a href="#"><img src="http://placehold.it/170x200" /></a>
<a href="#"><img src="http://placehold.it/170x200" /></a>
<a href="#"><img src="http://placehold.it/170x200" /></a>
<a href="#"><img src="http://placehold.it/170x200" /></a>
<a href="#"><img src="http://placehold.it/170x200" /></a>
</aside>
</section>
</div>
<footer id="main_footer">
<h1>๋ชจ๋ ์น ๋์์ด๋๋ฅผ ์ํ HTML5 + CSS3 ์
๋ฌธ</h1>
</footer>
</body>
</html>
๐ ์ ๋ฆฌ
width
์margin: 0 auto;
๋ฅผ ์ด์ฉํ์ฌ body ํ๊ทธ ์ค์ ์ ๋ ฌํ๊ธฐ- ์์ ํ๊ทธ์
position: absolute;
์ ์ฉ ์, ๋ถ๋ชจ ํ๊ทธ์position: relative;
์ ์ฉํ๊ธฐ - ์์ ํ๊ทธ์
float
์์ฑ ์ ์ฉ ์, ๋ถ๋ชจ ํ๊ทธ์overflow: hidden;
์ ์ฉํ๊ธฐ - ์คํ๋ผ์ดํธ ์ด๋ฏธ์ง์
background-position
์ ๋ํ ์ดํด