2021.07.16 CSS์‹ค์Šต(6)

hae.logยท2021๋…„ 7์›” 16์ผ
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;
	}


}

๐Ÿš€ ์‹ค๋ฌด๊ด€๋ จTip

๐Ÿ’ก 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๋กœ ์ถ”๊ฐ€ ํ•ด์„œ ์ ์šฉํ•˜๊ธฐ

0๊ฐœ์˜ ๋Œ“๊ธ€