ํฐ์คํ ๋ฆฌ ๋ทฐ
๐์ค๋๋ ์์ฑ๋ณธ ๋จผ์ ๐
header-search ๋ถ๋ถ์ css๊ฐ ์ฑ์์ง๋ ์ง์ ์ด๋ผ๊ณ ์๊ฐํ๋ฉด ๋ ๊ฒ ๊ฐ๋ค.
html
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>๋ค์ด๋ฒ</title> <!--์๋จ๋ฐ์ ๋จ๋ ์ด๋ฆ ํ์-->
<link rel="shortcut icon" type="image/x-icon" href="./favicon.ico"/>
<link rel="stylesheet" href="./naver.css">
</head>
<body>
<header>
<div id="header-center"> <!--๊ฐ์ด๋ฐ ์ ๋ ฌ์ฉ div -->
<div>
<span>๋ค์ด๋ฒ๋ฅผ ์์ํ์ด์ง๋ก</span>
<span>์ฅฌ๋์ด๋ค์ด๋ฒ</span>
<span>ํดํผ๋น</span>
</div>
<div id="header-search">
<a href="https://www.naver.com">
<h1>
<span>๋ค์ด๋ฒ</span>
</h1>
</a>
<h2 class="blind">๊ฒ์์ฐฝ</h2>
<fieldset>
<legend class="blind">๊ฒ์</legend>
<input />
<button>
<span class="blind">๊ฒ์</span>
<span id="search-image"></span>
</button>
</fieldset>
</div>
</div>
</header>
<nav>
<ul> <!-- unordered list ์ ๋ ฌ๋์ง ์์ ๋ฆฌ์คํธ--> <!--ol์ ์ ๋ ฌ ์ซ์-->
<li>๋ฉ์ผ</li> <!--list item๋ฆฌ์คํธ ์์ดํ
-->
<li>์นดํ</li> <!--list item๋ฆฌ์คํธ ์์ดํ
-->
<li>๋ธ๋ก๊ทธ</li> <!--list item๋ฆฌ์คํธ ์์ดํ
-->
<li>์ง์์ธ</li> <!--list item๋ฆฌ์คํธ ์์ดํ
-->
<li>์ผํ</li> <!--list item๋ฆฌ์คํธ ์์ดํ
-->
<li>๋ค์ด๋ฒํ์ด</li> <!--list item๋ฆฌ์คํธ ์์ดํ
-->
<li>๋ค์ด๋ฒ์ผํ</li>
</ul>
</nav>
<main>
<h2>์ค์๊ฐ ๊ฒ์์ด</h2>
<h3>์ฐํฉ๋ด์ค</h3>
<ol>
<li> ์ถฉ๊ฒฉ) ๋ฐฐ์ํ ๊ณต๋ถ ํ๊ธฐ ์ซ์ด ...</li>
<li> ์๋ณด) 11์๋ฌ ์์๋ html ๋๋ด์ผ .. </li>
</ol>
<h3>์ธ๋ก ์ฌ ๋ชฉ๋ก</h3>
<ul>
<li><img src="./๊ณต๊ฐ์ธ๋ก ๋ด์์ค.png" alt="๋ด์์ค" /></li>
<li><img src="./๊ตญ๋ฏผ์ผ๋ณด.png" alt="๊ตญ๋ฏผ์ผ๋ณด"></li>
</ul>
<h3>๋ก๊ทธ์ธ</h3>
<h3>๋ด์ค</h3>
<h3>์ผํ</h3>
</main>
<footer>
<div>๊ณต์ง์ฌํญ</div>
<div>creators</div>
<div>ํ์ฌ์๊ฐ</div>
</footer>
</body>
</html>
CSS
*{
box-sizing:border-box;
}
/* Cascading Style Sheet */
/* ์ ํ์(Selector) */
.blind {
position: absolute;
overflow: hidden;
clip: rect(0 0 0 0);
margin: -1px;
width: 1px;
height: 1px;
}
#header-center{
margin: 0 auto;
width: 1080px;
}
#header-search a{
text-decoration: none;
}
#header-search h1 {
width: 198px;
height: 48px;
display: inline-block;
/*background-image: url(./sp_search.png);
background-position: -4px -10px;
background-repeat: no-repeat;*/
background: url(./sp_search.png) -4px -4px no-repeat;
vertical-align: middle;
position: relative;
top: -6px
}
#header-search h1 span {
display: none;
}
/*์์์ ํ์*/
#header-search h2 {
display: none;
}
#header-search fieldset {
margin-left: 20px;
/*padding-top: 12px;
padding-bottom: 12px;
padding-left: 10px;
padding-right: 0;*/
padding: 12px 0 12px 10px;
width:521px;
height:49px;
display: inline-block;
border: 2px solid #03cf5d;
vertical-align: middle;
position: relative;
}
#header-search fieldset input {
border: none;
padding: 0;
outline: none;
vertical-align: top;
width: 405px;
height: 23px;
}
#header-search fieldset button {
height: 49px;
width: 49px;
border: none;
padding: 0;
background: #03cf5d; /*background์ ๋ค๋ฅธ ์ด๋ฏธ์ง๋ ๋ฃ์ ์ ์์ง๋ง ์ปฌ๋ฌ๋ ๋ฃ์ ์ ์์*/
/*background-size: 30px 30px; ํ๋ ค๊ณ ํ๋๋ ์ด๋ฏธ์ง ์์ฒด์ ํฌ๊ธฐ๊ฐ ์์์ง*/
position: absolute;
right: -2px;
top: -2px;
}
#search-image {
background-image:url(./sp_search.png);
background-position: -3px -60px;
background-repeat: no-repeat;
width: 21px;
height: 21px;
display: inline-block;
margin: 14px;
}
[HTML,CSS] ํด๋์ค(class) ์์ฑ
1. html์์์ ํด๋์ค
ํด๋์ค(class)๋ ์์๋ค์ ํน์ ํด๋์ค๋ก ๋ฌถ๋ ์์ฑ์ด๋ค.
html์์ ํด๋์ค ์์ฑ์ ์ฃผ๋ก ๋์ผํ ํด๋์ค์ ์ํ ์์๋ค์๊ฒ ๋์ผํ ์คํ์ผ์ ์ ์ฉํ๋ ์ฉ๋๋ก ์ฌ์ฉ๋๋ค.
โ id์ class ์ฐจ์ด
๋จผ์ , id ์์ฑ์ ํ๊ทธ์ ์ ์ผํ ์ด๋ฆ์ ๋ถ์ด๊ณ ์ถ์ ๋ ์ฌ์ฉํ๋ค. ๊ทธ๋ฌ๋ class ์์ฑ์ ๊ฐ์ ์ ํ์ผ๋ก ๋ฐ๋ณต๋๋ ํ๊ทธ๋ค์ ์ ํ๋ณ๋ก ๋ถ๋ฅํ๊ณ ์ถ์ ๋ ์ด๋ค.
์ฆ, id ์์ฑ์ ๋จ ํ๋์ ์์์๋ง ์ธ ์ ์๊ธฐ ๋๋ฌธ์ ์ค๋ณต์ด ๋ถ๊ฐ๋ฅํ๋ class ์์ฑ์ ์ ํ๋ณ๋ก ๋์ผํ class๋ฅผ ์ธ ์ ์๊ธฐ ๋๋ฌธ์ ์ค๋ณต์ด ๊ฐ๋ฅํ๋ค.
2. css์์์ ํด๋์ค
CSS์์ ํด๋์ค์ ๋ฐ๋ผ์ ์์๋ฅผ ์ ํํ๋ ค๋ฉด ์์์ ํด๋์ค๋ฅผ ์ (.)์ผ๋ก ์ด์ด ํด๋์ค ์ ํ์๋ฅผ ๋ง๋ค๋ฉด ๋๋ค.
โ ํ์
ํด๋์ค(class)์ ์ํ ์์ ์ค ํน์ ์์๋ง ์ ํ : ์์๋ช .ํด๋์ค๋ช
ํน์ ํด๋์ค(class)์ ์ํ ์์๋ค์ ๋ชจ๋ ์ ํ: ๋ ์์ ์์๋ช ์ ์๋ตํ์ฌ .ํด๋์ค๋ช ํ์์ผ๋ก ์์ฑ
p.sohyunee /*sohyuneeํด๋์ค์ p์์*/
.sohyunee /*sohyuneeํด๋์ค์ ๋ชจ๋ ์์*/
โid์ class์ ์ฐจ์ด์
id | class |
#์ผ๋ก ์ ํ | . ์ผ๋ก ์ ํ |
ํ ๋ฌธ์์ ๋จ ํ๋์ ์์์๋ง ์ ์ฉ | ๋์ผํ ๊ฐ์ ๊ฐ๋ ์์ ๋ง์ |
ํน์ ์์์ ์ด๋ฆ์ ๋ถ์ด๋ ๋ฐ ์ฌ์ฉ | ์คํ์ผ์ ๋ถ๋ฅ(classification)์ ์ฌ์ฉ |
๋ค์ด๋ฒ ํํ์ด์ง์์ ๊ฒ์์ฐฝ ๋ถ๋ถ์ ๊ธ์จ๋ค์ ์น ์ ๊ทผ์ฑ์ ์ํ blind ์ฒ๋ฆฌ๊ฐ ํ์ํ๊ธฐ ๋๋ฌธ์ blind ๋ผ๋ ํด๋์ค๋ก ๋ฏธ๋ฆฌ ๋ฌถ์ด์ค๋ค. ์ฌ๊ธฐ์ ์น ์ ๊ทผ์ฑ์ ์ํ blind ์ฒ๋ฆฌ๋ ์๊ฐ์ฅ์ ์ธ ์ ์ ๋ค์ ์ํด css์๋ ์๋ณด์ด์ง๋ง ์คํฌ๋ฆฐ ๋ฆฌ๋์๋ ์ฝํ๊ฒ๋ ํ๋ ๊ฒ์ ์๋ฏธํ๋ค.
<h2 class="blind">๊ฒ์์ฐฝ</h2>
<fieldset>
<legend class="blind">๊ฒ์</legend>
<input />
<button>
<span class="blind">๊ฒ์</span>
<span id="search-image"></span>
</button>
</fieldset>
[CSS] ์น ์ ๊ทผ์ฑ์ ์ํ CSS blind ์ฒ๋ฆฌ
์ฝํ ์ธ ๋ฅผ ์จ๊ธฐ๋ ๋ฐฉ๋ฒ ์ค
display: none / visibility: hidden / font-size:0 / line-height: 0 / width:0 / height:0 ๊ณผ ๊ฐ์ด ์ฝํ ์ธ ๋ฅผ ์จ๊ธธ ์ ์์ง๋ง ์คํฌ๋ฆฐ ๋ฆฌ๋๋ก ์ฝ์ ์ ์๊ธฐ ๋๋ฌธ์ ์ ๊ทผ์ฑ์ ๋ฌธ์ ๊ฐ ์๋ค. ์๋ํ๋ฉด ์๊ฐ์ฅ์ ์ธ๋ค๊ณผ ๊ฐ์ ์ ์ ๋ค์ด ์กด์ฌํ๊ธฐ ๋๋ฌธ์ด๋ค.
์ฆ, ์คํฌ๋ฆฐ ๋ฆฌ๋์๋ ๋ณด์ด๋ ๋์๋ ์๋ณด์ด๊ฒํ๋ ์น ์ ๊ทผ์ฑ์ ๊ณ ๋ คํ ์ฝํ ์ธ ์จ๊ธฐ๋๋ฐ ๋ฌธ์ ๊ฐ์๋ clip ์์ฑ์ ํ์ฉํด์ผ ํ๋ค.
โ ๊ทธ๋ฌ๋ clip ์์ฑ์ ํ์ฉํ๋ค๊ณ ๋ฌด์กฐ๊ฑด ์คํฌ๋ฆฐ ๋ฆฌ๋๊ฐ ์ฝ์ ์ ์๋ ๊ฒ์ด ์๋๋ผ, ์๋ฆฌ๋จผํธ์ ์ฌ์ด์ฆ๋ฅผ ์ต์ 1px ์ด์์ผ๋ก ์ ์ฉํด์ผ ํ๋ค. (1px๋ณด๋ค ์์ผ๋ฉด ์คํฌ๋ฆฐ ๋ฆฌ๋๊ฐ ๋ชป์ฝ์)
[CSS] clip ์์ฑ
clip ์์ฑ์ ์์์ ํน์ ๋ถ๋ถ๋ง ๋ณด์ด๊ฒ ํ๋ ์์ฑ์ด๋ค.
์ด๋ฏธ์ง๋ค์ ๊ฐ์ ์ชผ๊ฐ ๋ณด๋ด๋ฉด ๋ธ๋ผ์ฐ์ ์์ ์ง์์ ํ์ง ์๋ ๋ฑ์ ํ๊ณ๊ฐ ์๊ธฐ ๋๋ฌธ์ ํ๋ฐฉ์ ์์ฒญ์ด ๊ฐ๋ ํ์ฅ์ ์ด๋ฏธ์ง๋ฅผ ์ด์ฉํ๋ ๊ฒ์ ์ด๋ฏธ์ง ์คํ๋ผ์ดํธ๋ผ๊ณ ํ๋ค. ๋ฐ์ ์๋ ์ด๋ฏธ์ง ์ ์ฒด์์ header-search ์์ ํ์ฉํ ๋ถ๋ถ์ ์ผ๋ถ์ด๊ธฐ ๋๋ฌธ์ clip ์์ฑ์ ํ์ฉํด์ ์ด๋ฏธ์ง๋ฅผ ์๋ผ์ค๋ค.
๋ผ
โ๋ฌธ๋ฒ: clip: auto/ shape / inital / inherit
auto: ์์์ ๋ชจ๋ ๋ถ๋ถ
shape: ํน์ ๋ถ๋ถ์ด ๋์ค๋๋ก ์ค์
- ํน์ ๋ถ๋ถ๋ง ๋์ค๊ฒ ํ ๋๋ ๋ค์๊ณผ ๊ฐ์ ์ฝ๋๋ก ๋์ค๋ ๋ถ๋ถ์ ์ ํ๋ค.
- rect (<top>, <right>, <bottom>, <left>)
<top> : ์๋ฅผ ๊ธฐ์ค์ผ๋ก ์์ํ๋ ์์น
<right> : ์ผ์ชฝ์ ๊ธฐ์ค์ผ๋ก ๋๋๋ ์์น
<bottom> : ์๋ฅผ ๊ธฐ์ค์ผ๋ก ๋๋๋ ์์น
<left>: ์ผ์ชฝ์ ๊ธฐ์ค์ผ๋ก ์์ํ๋ ์์น
initial: ๊ธฐ๋ณธ๊ฐ์ผ๋ก ์ค์
inherit: ๋ถ๋ชจ ์์์ ์์ฑ๊ฐ์ ์์๋ฐ์
/* ์ ๊ทผ์ฑ์ ๋ฌธ์ ๊ฐ ์์ */
.blind {
display: none; /*ํ๋ฉด์ ๋ณด์ด์ง ์๊ณ ์คํฌ๋ฆฐ ๋ฆฌ๋๋ ์ฝ์ด์ฃผ์ง ์์*/
}
.blind {
visibility: hidden; /* ํ๋ฉด์ ๋ณด์ด์ง ์๊ณ ์คํฌ๋ฆฐ ๋ฆฌ๋๋ ์ฝ์ด์ฃผ์ง ์์*/
}
/* ์ ๊ทผ์ฑ์ ๋ฌธ์ ์์ */
.blind {
position: absolute;
width: 1px;
height: 1px;
clip: rect(0 0 0 0);
overflow: hidden;
}
์ ๊ทผ์ฑ์ ๋ฌธ์ ๊ฐ ์๋ ์ฝ๋๋ฅผ ํ๋ํ๋ ์ดํด๋ณด์๋ฉด,
[CSS] position ์์ฑ
CSS์์ position ์์ฑ์ HTML ๋ฌธ์ ์์์ ์์๊ฐ ๋ฐฐ์น๋๋ ๋ฐฉ์์ ๊ฒฐ์ ํ๋ค. ์ฆ, ํ๊ทธ๋ค์ ๋ฐฐ์นํด์ฃผ๋ ์ญํ ์ด๋ผ๊ณ ์๊ฐํ๋ฉด ๋ ๊ฒ ๊ฐ๋ค.
๐คฆโ๏ธ ์ดํดํ๊ธฐ ์ด๋ ต๊ณ ๊ธ๋ ๋ง์์ ๋ฐ๋ก ๊ธ ์ ๋ก๋ ํ์ผ๋ ์ฐธ๊ณ ๐คฆโ๏ธ
๋งํฌ : https://sohyxzn.tistory.com/5
[CSS] position (ํฌ์ง์ ) ์์ฑ
position์ ๋ฌธ์ ์์ ์์๋ฅผ ๋ฐฐ์นํ๋ ๋ฐฉ์์ด๋ค. top, right, bottom, left ์์ฑ์ด ์์๋ฅผ ๋ฐฐ์นํ ์์น๋ฅผ ๊ฒฐ์ ํ๋ค. position ๊ฐ๋ ์ ์ดํดํ๊ธฐ ์ ์ ์์์ผํ ํน์ง์ position ์์ฑ์ ์์๋์ง ์๋๋ค๋ ๊ฒ์ด
sohyxzn.tistory.com
[CSS] overflow ์์ฑ
CSS์ overflow๋ ์์๋ด์ ์ฝํ ์ธ ๊ฐ ๋๋ฌด ์ปค์ ์์๋ด์ ๋ชจ๋ ๋ณด์ฌ์ฃผ๊ธฐ ํ๋ค๋ ๊ทธ๊ฒ์ ์ด๋ป๊ฒ ๋ณด์ฌ์ค์ง๋ฅผ ์ง์ ํ๋ค.
์ฆ, ํน์ ์์์ ์์ ์์๊ฐ ๋ถ๋ชจ ์์์ ๋ฒ์๋ฅผ ์ด๊ณผํ ๋ ์ด๋ป๊ฒ ์ฒ๋ฆฌํ ์ง๋ฅผ ๊ฒฐ์ ํ ์ ์๋ ์์ฑ์ด๋ค.
์์ ์์๊ฐ ๋ถ๋ชจ์์์ ๋ฒ์๋ฅผ ์ด๊ณผํ ๋ ์ด๋ป๊ฒ ์ฒ๋ฆฌํ ์ง๋ฅผ ๊ฒฐ์ ํจ์ผ๋ก ๋ถ๋ชจ์์์ overflow ์์ฑ ๊ฐ์ ๊ฒฐ์ ํด์ฃผ์ด์ผ ํ๋ค.
-๋ฌธ๋ฒ
overflow: visible / hidden / scroll / auto
visible
ํน์ ์์๊ฐ ๋ฐ์ค๋ฅผ ๋์ด ๊ฐ๋๋ผ๋, ๊ทธ๋๋ก ๋ณด์ฌ์ค๋ค
hidden
๋ถ๋ชจ์์์ ๋ฒ์๋ฅผ ๋์ด๊ฐ๋ ์์์์์ ๋ถ๋ถ์ ๋ณด์ด์ง ์๊ฒ๋๋ค
scroll
๋ถ๋ชจ์์์ ๋ฒ์๋ฅผ ๋์ด๊ฐ๋ ์์์์์ ๋ถ๋ถ์ ๋ณด์ด์ง ์์ง๋ง ์ฌ์ฉ์๊ฐ ํ์ธํ ์ ์๋๋ก ์คํฌ๋กค๋ฐ๋ฅผ ํ์ํด์ค๋ค.
auto
๋ถ๋ชจ์์์ ๋ฒ์๋ฅผ ๋์ด๊ฐ๋ ์์์์์ ๋ถ๋ถ์ด ์์ ๊ฒฝ์ฐ ํด๋น ๋ถ๋ถ์ ๋ณด์ด์ง ์๋๋ก ์ฒ๋ฆฌํ๊ณ ์ฌ์ฉ์๊ฐ ํด๋น ๋ถ๋ถ์ ํ์ธํ ์ ์๋๋ก ์คํฌ๋กค๋ฐ๋ฅผ ํ์ํ๋ค
์๊น์ ์ blind์ ํด๋์ค๋ก ๋ฌถ์ด๋ ๊ฒ๋ค์ ๋ชจ๋ blind ์ฒ๋ฆฌ ํด์ค๋ค. blind ์์ฑ๋ค ์๊ธฐํด๋๊ธฐ
.blind {
position: absolute;
overflow: hidden;
clip: rect(0 0 0 0);
margin: -1px;
width: 1px;
height: 1px;
}
๋ค์ด๋ฒ ๊ฒ์์ฐฝ์ ์ ์ฉํ ๋ ์ฐ๋ฆฌ๋ ์ฝํ ์ธ + ๋ณด๋ + ํจ๋ฉ๊น์ง ํฉํ๊ฑฐ๋ฅผ ์ํ์ง๋ง ์ค์ ๋ก ๋ธ๋ผ์ฐ์ ๊ฐ ๋ํ๋ด๋ ๊ฒ์ ์ค์ง ์ฝํ ์ธ ์ผ ๋ฟ์ธ ์ํ์ฐฉ์ค๋ฅผ ๊ฒช์ ์ ์๋ค. ์ด๋ ํ์ํ ๊ฐ๋ ์ด ๋ฐ๋ก ๋ฐ์ค ๋ชจ๋ธ์ด๋ค.
[CSS] ๋ฐ์ค ๋ชจ๋ธ
[CSS] ๋ฐ์ค ๋ชจ๋ธ(Box-Model)
๐ ๋ฐ์ค ๋ชจ๋ธ HTML์ ์์๋ ๋ฐ์ค ๋ชจ๋ธ๋ก ๋์ด ์๋ค. ํ๊ทธ๋ฅผ ํตํด ์์๋ฅผ ๋ง๋ค ๋๋ง๋ค ์๋ก์ด box ๊ฐ ์๊ธฐ๊ณ ๊ทธ ๋ฐ์ค์ style์ ์ฃผ์ด ๋ฌธ์๋ฅผ ๊พธ๋ฐ ์ ์๊ฒ ๋๋ ๊ฒ์ด๋ค. ๋ธ๋ผ์ฐ์ ๋ ๋ฐ์ค ๋ชจ๋ธ์ ํฌ๊ธฐ
sohyxzn.tistory.com
[CSS] box - sizing ์์ฑ
: box-sizing ์์ฑ์ width, height ์์ฑ์ ๋์ ์์ญ์ ๋ณ๊ฒฝํ ์ ์๋ค.
box-sizing ์์ฑ์ ๊ธฐ๋ณธ ๊ฐ์ content-box์ด๋ค. ์ด๋ width, height ์์ฑ์ ๋์์์ญ์ด content ์์ญ์ ์๋ฏธํ๋ค.
์ฆ, box-sizing ์์ฑ์ ๊ฐ์ border-box๋ก ์ง์ ํ๋ฉด ๋ง์ง์ ์ ์ธํ ๋ฐ์ค ๋ชจ๋ธ ์ ์ฒด๋ฅผ width,height ์์ฑ์ ๋์ ์์ญ์ผ๋ก ์ง์ ํ ์ ์๊ฒ ํ๋ค.
์ฐ๋ฆฌ๊ฐ ์ํ๋ ๊ฒ์ฒ๋ผ ๋ค์ด๋ฒ ๊ฒ์์ฐฝ์ ์ ์ฉํ๊ธฐ ์ํด ๋ชจ๋ css์ borderbox๋ฅผ ์ ๋ ฅํด์ค๋ค.
*{
box-sizing:border-box;
}
ํ์ ํ๊ทธ์์๋ css์ ๋๋ฎ์ด๊ฐ ์๋ง์ ์ ์๋ค. ์๋ํ๋ฉด height ๊ฐ์ด ๋ค๋ฅด๊ธฐ ๋๋ฌธ์ด๋ค.
(a ํ๊ทธ ์์ ์๋ fieldset ์ ๋ ฌ ๊ฐ๊ฒํ ๋ ์ ์ฉ)
์ด๋๋ vertical-align ์์ฑ์ ํ์ฉํด์ฃผ๋ฉด ๋๋ค.
[CSS] vertical-align ์์ฑ
vertical-align ์ ์ธ๋ผ์ธ ๋ธ๋ก ๋ฑ์ ํฌํจํ ๋ชจ๋ ์ธ๋ผ์ธ์์์ ์์ง ์ ๋ ฌ์ ์ํด ์ฌ์ฉ๋๋ค.
์ ์ฉ๋์์ ์ธ๋ผ์ธ ์์์ ํ ์ด๋ธ ์ ์ด๋ค.
์ ์์ฌํญ:
1) inline์ด๋ inline-block ์์์๋ง ์ ์ฉ์ด ๋๋ค. ๋ฐ๋ผ์ block ์์์ธ <div>๋ ์ ์ฉ๋์ง ์๋๋ค.
2) ์์ ์์ฒด๋ง์ ์ ๋ ฌํ๊ณ , ๋ด์ฉ์๋ ์ํฅ์ ๋ฏธ์น์ง ์๋๋ค. ๋จ, table cell์ ์ ์ฉํ ๋๋ ์ํฅ์ ๋ฏธ์นจ
3) vertical - align ์ ์ ๋ ฌํ๋ ค๋ ์์๋ฅผ ๋ค๋ฅธ ์ธ๋ผ์ธ ์์์ ์๋์ ์ผ๋ก ์ ๋ ฌํ๊ธฐ ๋๋ฌธ์ ๊ฐ์ ์ค์์ ์ธ๋ผ์ธ ์์์ ํฌ๊ธฐ์ ๋ฐ๋ผ ๋๋ฎ์ด๊ฐ ๋ฌ๋ผ์ง ์ ์๊ณ ๋ ๊ทธ ์ค์ ์๋ line-height ์ค์ ์ ๋ฐ๋ผ์๋ ๋ฌ๋ผ์ง ์ ์๋ค.
#header-search h1 {
width: 198px;
height: 48px;
display: inline-block;
background: url(./sp_search.png) -4px -4px no-repeat;
vertical-align: middle;
position: relative;
top: -6px
}
์ฌ๊ธฐ์ ์ค์ ํ verical - align: middle; ์ ๋ถ๋ชจ ์์ ์ค์์ ์์นํ๋ผ๋ ๋ป์ด๋ฏ๋ก header-search ์ ๋ถ๋ชจ์ธ header-center์ ์ค์์ ์์น๋๊ฒ ๋ค. vertical-align ์์ฑ์ ์ฌ์ฉํ๊ณ ๋ ๋ง์ง ์๋ ๊ฒฝ์ฐ์๋ position์ ํ์ฉํ๋ฉด ๋๋ค.
์ด์ ๋ฒํผ์ ๋ณด์ด๊ฒํ๊ณ ๋ฒํผ์ด๋ผ๋ ๊ธ์๋ ์๋ณด์ด๊ฒ ํด์ผํ๋ ๋ณด์ด์ง ์๊ณ ์ถ์ ๋ถ๋ถ (ํ๊ฒ)์ blind๋ฅผ ๋ฃ์ด์ค๋ค.
<button>
<span class="blind">๊ฒ์</span>
<span id="search-image"></span>
</button>
์ด์ ๋ฐ๋ผ์ ๋ฒํผ์๋ ๊ธฐ๋ณธ css๊ฐ ์ ์ฉ๋์ด ์๊ธฐ ๋๋ฌธ์ ์ด๋ฅผ ์์ ์ค๋ค.
#header-search fieldset button {
height: 49px;
width: 49px;
border: none;
padding: 0;
position: absolute;
right: -2px;
top: -2px;
}
์ฌ์ง์์ ์ํ๋ ๋ถ๋ถ์ ๋ฃ๊ธฐ ์ํด background-size๋ฅผ ์๋ํด๋ณด๋ ์ฌ์ง ์์ฒด์ ํฌ๊ธฐ๊ฐ ๋ฐ๋ ๋ฟ ์๋ฆฌ์ง ์๋๋ค.
๋ฐ๋ผ์, span์ ํ์ฉํด ๊ฒ์์ฉ ์ด๋ฏธ์ง๋ฅผ ๋ฐ๋ก ๋๋ค. ์๋๋๋ก ์ด๋ฆ์ ๋ถ์ด์๋ฉด # header - search fieldset button.search-image ์ธ๋ฐ ๋๋ฌด ๊ธธ์ด ๊ฐ๋ ์ฑ์ด ์ข์ง ์๋ค. ๋ฐ๋ผ์ html์ id๋ฅผ ํตํด ๊ฐ๋ตํ ์ด๋ฆ์ search-image ๋ผ๊ณ ์ง์ด์ค๋ค.
HTML
<button>
<span class="blind">๊ฒ์</span>
<span id="search-image"></span>
</button>
CSS
#search-image {
background-image:url(./sp_search.png);
background-position: -3px -60px;
background-repeat: no-repeat;
width: 21px;
height: 21px;
display: inline-block;
margin: 14px;
}
์ฌ๊ธฐ์ display๋ฅผ inline-block์ผ๋ก ๋ฐ๊ฟ width์ height๋ฅผ ์กฐ์ ํ ์ ์๊ฒ ํ๊ณ background-position์ ํ์ฉํด ์์น๋ฅผ ์ก์์ค๋ค.
'WEB > html.css' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๋ค์ด๋ฒ html ๊ตฌํํ๊ธฐ _ 03. ZeroCho 2๊ฐ ์ ๋ฆฌ (1) | 2022.11.29 |
---|---|
๋ค์ด๋ฒ html ๊ตฌํํ๊ธฐ _ 02. ZeroCho 1๊ฐ ์ ๋ฆฌ (1) | 2022.11.24 |
๋ค์ด๋ฒ html ๊ตฌํํ๊ธฐ _ 01. HTML/CSS๋ ? (0) | 2022.11.21 |