htmlโ
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="๋ด๋งํฌ ์ผํ๋ชฐ ์นดํผ์บฃ ์ฐ์ต">
<meta name="author" content="์ํ์ฑ">
<meta name="keywords" content="html. css, tutorial">
<title>Helbak</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<header id="header">
<h1>
<a href="#" class="logo">
<img src="https://via.placeholder.com/186x18">
</a>
</h1>
<nav class="buttons">
<ul>
<li>
<a href="#" class="menu-button">
<img src="https://via.placeholder.com/22x20">
</a>
</li>
<li>
<a href="#" class="menu-button">
<img src="https://via.placeholder.com/22x20">
</a>
</li>
<li>
<a href="#" class="menu-button">
<img src="https://via.placeholder.com/22x20">
</a>
</li>
</ul>
</nav>
</header>
<main role=main class="main-content">
<ul class="product-group">
<li>
<a href="#" class="product-group-link">
<article>
<h2 class="link-text">Product 1</h2>
<img src="https://via.placeholder.com/1000x563">
</article>
</a>
</li>
<li>
<a href="#" class="product-group-link">
<article>
<h2 class="link-text">Product 2</h2>
<img src="https://via.placeholder.com/1000x563">
</article>
</a>
</li>
<li>
<a href="#" class="product-group-link">
<article>
<h2 class="link-text">Product 3</h2>
<img src="https://via.placeholder.com/1000x563">
</article>
</a>
</li>
<li>
<a href="#" class="product-group-link">
<article>
<h2 class="link-text">Product 4</h2>
<img src="https://via.placeholder.com/1000x563">
</article>
</a>
</li>
<li>
<a href="#" class="product-group-link">
<article>
<h2 class="link-text">Product 5</h2>
<img src="https://via.placeholder.com/1000x563">
</article>
</a>
</li>
<li>
<a href="#" class="product-group-link">
<article>
<h2 class="link-text">Product 6</h2>
<img src="https://via.placeholder.com/1000x563">
</article>
</a>
</li>
</ul>
</main>
<footer id="footer">
<nav class="left-nav">
<ul>
<li><a href="#">Terms and conditions</a></li>
<li><a href="#">Cookies</a></li>
</ul>
</nav>
<nav class="right-methods">
<h3>Payment Methods</h3>
<ul>
<li><span class="payment-icon one"></span></li>
<li><span class="payment-icon two"></span></li>
<li><span class="payment-icon three"></span></li>
<li><span class="payment-icon four"></span></li>
<li><span class="payment-icon five"></span></li>
</ul>
</nav>
<a href="#" class="to-top-button"></a>
</footer>
</body>
</html>
cssโ
/* ๋ชจ๋ฐ์ผ๋ฒ์ */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
๐ padding์ผ๋ก ์ธํด ๊ณต๊ฐ์ ํฌ๊ธฐ๊ฐ ๋ฌ๋ผ์ง๋ ๊ฒ์ ๋ฐฉ์งํ๊ธฐ ์ํด ๋ฃ์ด์ค
๐ * { } = margin๊ณผ padding๊ฐ์
๊ธฐ๋ณธ์ ์ผ๋ก ๊ฐ๊ณ ์๋ ํ๊ทธ(html, body, h1, h2, h3, pํ๊ทธ ๋ฑ) ๋ค์
ํ๋ฒ์ ์ ์ฉ๊ฐ๋ฅ
}
html ,body {
width: 100%;
height: 100%;
}
๐์น์ฌ์ดํธ ์ ์์ ๋ํดํธ๊ฐ์ผ๋ก ๋ฃ์ด์ฃผ๊ธฐ
bodyํ๊ทธ์ ์ ์ฒด ์์ญ์ ํ์ธ๊ฐ๋ฅํ๊ธฐ ๋๋ฌธ์ ๋ฃ์ด์ค์ผํจ
body {
overflow-x: hidden;
font-family: sans-serif;
color: #585858;
}
h1, h2, h3, h4, h5, h6, p {
font-weight: 400;
}
li {
list-style: none;
}
a {
text-decoration: none;
}
img {
vertical-align: middle;
}
span {
display: block;
}
#header h1 {
background-color: yellow;
}
#header h1 .logo {
position: relative;
display: block;
width: 100%;
height: 65px;
/*background-color: yellow;*/
}
#header .logo img {
position: absolute;
top: 0;
margin-top: 12px;
left: 50%;
margin-left: -93px;
}
#header .buttons li{
overflow: hidden;
}
#header .buttons li {
position: relative;
float: left;
width: 33.333%;
height: 65px;
}
#header .buttons .menu-button {
display: block;
width: 100%;
height: 100%;
text-align: center;
}
buttons ์์ ์๋ li ํ๊ทธ ์์์ 1๋ฒ์งธ๋ก ๋์ค๋
์์์์ญ ์์ ์๋ ๋ฉ๋ด๋ฒํผ์ ์ ํํ๊ฒ ๋ค!
๐ #header .buttons li:nth-child(1) .menu-button {
background-color: blue;
}
#header .buttons li:nth-child(2) .menu-button {
background-color: pink;
}
#header .buttons li:nth-child(3) .menu-button {
background-color: green;
}
๐ก y์ถ ์ค์์ ๋ ฌ ๊ณต์
top ๊ฐ์ฌ์ฉํ ๋๋ position relative ์ ์ฉํ๊ธฐ position relative๋ก
top ์ผ๋ก 50% ๋ฐ์ผ๋ก ๋ด๋ ค์ฃผ๊ณ transform ์ translateY(-50)ํด์ฃผ๋ฉด
y์ถ ์ค์์ ๋ ฌ์ด๋๋ค.
#header .buttons li .menu-button img {
position: relative;
height: 20px;
top: 50%;
transform: translateY(-50%);
}
/* pc๋ฒ์ */
/* 1em = 16px */
@media (min-width: 47em) {
#header {
position: fixed;
width: 100%;
height: 80px;
top: 0;
left: 0;
z-index: 99999;
}
#header h1 {
width: 50%;
}
#header h1 .logo {
width: 280px;
height: 80px;
}
#header .logo img{
margin-top: 30px;
}
#header .buttons {
position: absolute;
width: 50%;
left: 50%;
top: 0;
}
#header .buttons li {
height: 80px;
}
}
/* ๋ชจ๋ฐ์ผ๋ฒ์ */
.main-content .product-group-link {
position: relative;
display: block;
/*float: left;*/
width: 100%;
height: 56.25%;
border: solid 10px red;
overflow: hidden;
}
.main-content .product-group-link img {
width: 100%;
height: 100%;
}
.main-content .product-group-link .link-text {
position: absolute;
left: 25px;
bottom: 25px;
color: black;
font-size: 25px;
}
/* pc๋ฒ์ */
@media (min-width: 47em) {
.main-content {
padding-top: 80px;
}
}
@media (min-width: 62em) {
.main-content {
overflow: hidden;
}
.main-content .product-group-link {
float: left;
width: 50%;
height: 28.125%;
}
}
#footer {
position: relative;
/*background-color: yellow;*/
padding-bottom: 66px;
}
#footer .left-nav {
padding-top: 20px;
text-align: center;
}
#footer .left-nav li {
padding: 5px 0;
}
#footer .right-methods {
text-align: center;
margin-bottom: 20px;
margin-top: 30px;
}
#footer .right-methods li {
display: inline-block;
padding: 7px 4px;
}
#footer .right-methods .payment-icon {
display: inline-block;
width: 30px;
height: 20px;
}
#footer .right-methods .payment-icon.one {
background-color: black;
}
#footer .right-methods .payment-icon.two {
background-color: red;
}
#footer .right-methods .payment-icon.three {
background-color: pink;
}
#footer .right-methods .payment-icon.four {
background-color: blue;
}
#footer .right-methods .payment-icon.five {
background-color: gray;
}
#footer .to-top-button {
position: absolute;
display: block;
width: 66px;
height: 66px;
background-color: green;
bottom: 0;
left: 50%;
margin-left: -33px;
}
/* pc๋ฒ์ */
@media(min-width: 60em) {
#footer {
height: 66px;
}
#footer .left-nav {
float: left;
width: 50%;
background-color: yellow;
text-align: left;
padding-top: 32px;
padding-left: 40px;
}
#footer .right-methods {
float: right;
width: 50%;
background-color: yellowgreen;
margin: 0;
padding-top: 32px;
padding-right: 40px;
text-align: right;
}
#footer ul, #footer li, #footer h3 {
display: inline-block;
vertical-align: middle;
}
#footer .left-nav a {
font-size: 14px;
padding: 0 5px;
}
#footer .right-methods li {
padding: 0 4px;
}
#footer h3 {
padding-right: 10px;
}
}
๐ก id์ ์ด๋ฆ์ ํ๋์ ๋ฌธ์(html)์ 1๊ฐ๋ง ์์ด์ผํ๋ค.
<ul>
<li><a href="https://www.naver.com">one</a></li>
<li><a href="contact.html">two</a></li>
<li><a href="#three">three</a></li>
```
href์์ฑ๊ฐ์ผ๋ก ์ ํ๋ค๋ฅธhtml๋ฌธ์ url์ฃผ์ id์์ฑ๊ฐ ์ด ๋ค์ด๊ฐ์ ์๋ค .id์ด๋ฆ์ด ๊ฐ์๊ฒฝ์ฐ html์ ๊ฒฐ๊ณผ์์ ํด๋ฆญํ์๋ ์ด๋ค ์น์ ์ผ๋ก ์ด๋ํ ์ง ๋ฏธ์ ์ด๊ธฐ๋๋ฌธ์ ๋ํดํธ ๊ฐ์ผ๋ก #๋ฃ์ด์ค์ผํจ.
class๋ก๋ aํ๊ทธ์ ๊ฒฐํฉ๋ถ๊ฐ
aํ๊ทธ์์ ๋ค์ด๊ฐ์์๋ ์์ฑ๊ฐ์ผ๋ก๋ id ๊ฐ ๋ค์ด๊ฐ์ ์๊ณ id์์ฑ๊ฐ์ผ๋ก๋ ํ๋์ ๋ฌธ์์์ ์ ์ผํด์ผํ๋ค
</ul>
<div id="one">One</div>
<div id="two">Two</div>
<div id="three">Three</div>
๐ก ์์ฌ์ด ๋ฐฐ์น์์
.text-box {
width: 200px;
height: 200px;
background-color: yellow;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis
}
๊ธ์๋ฅผ๊ฐ์ธ๋ ๊ณต๊ฐ์ ํฌ๊ธฐ๋ฅผ ๋์ด๊ฐ์๋ ์๋์ผ๋ก ์ค๋ฐ๊ฟ ํ์์ด ์ผ์ด๋๋๋ฐ,
white-space: nowrap; ์ค๋ฐ๊ฟ ํ์์ ํ์ง ์๊ฒ ๋ค.
overflow: hidden; ๋ฒ์ด๋๋ ์์ญ์ ๋ชจ๋ ๊ฐ์ถ๊ณ ์ถ๋ค.
text-overflow: ellipsis : ์์ญ์ ๋ฒ์ด๋๋ ์์ญ์ ๋ง์ค์ํ๋ฅผ ์ฌ์ฉํ๊ฒ ๋ค.
๋ง์ค์์ ๋ด๋นํ๋ ํ๊ทธ๋ฅผ ๋ฏธ๋ฆฌ html์ ๋ฃ์ด์ฃผ๋ฉด ํธ๋ฆฌํ๋๊น ๋ฏธ๋ฆฌ ๋ฃ์ด์ฃผ๊ธฐ
โcss๋ฌธ์์์
.ellipsis {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
์ธ๊ฐ์ง ์ฝ๋๋ฅผ ๋ณต๋ถํด์ html ๋ฌธ์์ class: ellipsis๋ก ์ถ๊ฐ ํด์ ์ ์ฉํ๊ธฐ