๊ดํธ ์์ ์ ์ฌ์น์ฐ์ฐ
width, height, margin, padding๋ฑ๋ฑ ๊ฐ๋ฅ
๊ฐ์ ๊ณ์ฐํ๊ธฐ ์ด๋ ค์ธ๋ ํธํ๊ฒ ๊ณ์ฐํด์ค๋ค!
๋ฐ์ํ์ฒ๋ผ ๋ธ๋ผ์ฐ์ ํฌ๊ธฐ์ ๋ฐ๋ผ ์์์ ๋๋น์ ๋์ด๊ฐ ๋ณํํด์ผํ๋ ๊ฒฝ์ฐ ์ฌ์ฉ
width : clac(100% / 3) - w100% ๋ฅผ 3๋ฑ๋ถ ์ํจ๋ค.
width : clac((100% - px) / 3) - w100% -px๋บ w๋ฅผ 3๋ฑ๋ถํ๋ค.
โ ์๋ค๋ก ๋์ด์ฐ๊ธฐ ์ ์
โ calc ์คํ ๋ง ์ ์
์์์ ์์น๋ฅผ ์ก์์ฃผ๋๊ฒ
๊ตฌ์กฐ์งค๋ ์ ์ผ ์ค์
*ํน์ด์ - ์์ ์๋จ (float๋ณด๋ค ๋ ๋์ด ๋ธ, ์๊ธฐ๋ค๋ผ๋ฆฌ ๊ฒน์ณ์ง๊ธฐ๋ ํจ) ์ฌ๋ฐฑ๊ฐ ๋ฌด์ํจ
๋์ดํฐ
position: relative;
๋์์๋์ ๋ค
position: absolute;
position: relative;์๋ ๋ฐ๋์ absolute๊ฐ ๋์์ผํ๋ค.
- 1) static : ๊ธฐ๋ณธ๊ฐ
- 2) relative : ๊ธฐ์ค์ ์ก์์ฃผ๋ ์์ฑ(์์์ด๋ ์์ )
--๋ฐ๋ก ๋ฐ์ ์๋์ ๊ฐ ์ฌ๋ผ์จ๋ค.
--๋ณ๋์ ํ์์์ฑ ์์ด ์ฌ์ฉํ๋ฉด static๊ณผ ๋น์
--์ฃผ๋ก ์์(absolute๊ฐ ๋ค์ด์๋)๋ค์ ๊ธฐ์ค์ผ๋ก ์ก์์ค๋ค.- 3)absolute : ์์ ์์์ค์ ๊ธฐ์ค์ ์ก์ ์ ์๋ ์์๋ฅผ ๊ธฐ์ค์ผ๋ก ์์ง์ธ๋ค.
์๋ ์์น์์ ์ฌ๋ฐฑ์ด๋ ๋ค๋ฅธ ์์์ ๊ฒน์ณ์ผ ํ ๋ ์ฃผ๋ก ์ฌ์ฉ
*์ฌ๋ฐฉ๊ฐ ๊ธฐ๋ณธ์ผ๋ก ๊ฐ์ด ์ฌ์ฉํ ๊ฒ- 4)fixed: ๋ธ๋ผ์ฐ์ ๊ธฐ์ค ํน์ ์์น์ ๊ณ ์
->background-attachment๋ ๋ค๋ฅด๋ค.
์์ ์์๊ฐ relative๋ฅผ ๊ฐ์ง๊ณ ์์ด๋ ๋ฌด์
*์๋ฆฌ ์ง์ ์ ํด์ฃผ๋ฉด(ex ๋ฐ๋ left 0, top 0) ๋ฐ์ ์ ๋ค(๋ฐ๋)์ด๋ ๋ฐ๋ผ๋ค๋
*์ฌ์ด์ฆ ์์ฃผ๋ฉด ํ๋กฏ์ฒ๋ผ ํ์ํ ๋งํผ๋ง ์ฐจ์งํจ
*์ฌ๋ฐฉ๊ฐ ๊ธฐ๋ณธ์ผ๋ก ๊ฐ์ด ์ฌ์ฉํ ๊ฒ
top, left, bottom, right (๋จ์ - px, % )
๐position:relative๋ฅผ ์คฌ์๋ footer๊ฐ ์ฌ๋ผ์ค๋ ๊ฒฝ์ฐ๊ฐ ์๋ค.
position:relative๋ฅผ ์ด๊ธฐํ ์์ผ์ค์ผํ๋ค.
์กฐ์์ -> overflow:hidden
ํ๋๋ก ๋์ด์ ์ ๋ ฌ์์ผ์ค๋ค.
position๋ณด๋จ ๋ฎ๊ฒ ๋ ์๋ค.
๋ฐ๋์ ์ ๋ฐ์ ์ธ ๋ฐฐ๊ฒฝ์์ ๋ฃ๋๊ฑฐ๋ค.
left, right
float:left/right -> overflow:hidden
whith๊ฐ ์๋ ์์ญ ์ค์์ ๋ ฌ
์ฃผ๋ก ํฐ์์ญ์ ๊ธฐ์ค์ ์ก์๋ ์ฐ์
์ธ์ ์์ 1๋ฒ๋นผ๊ณ 2,3,4๋ง ์ ์ฉ๋๋ค. 1๋ฒ์ ์๋ฐ
.bottom-area li+li{}
-> ์ฒซ๋ฒ์งธ li๋ ์ ์ธํ๊ณ , 2๋ฒ์งธ li๋ถํฐ ์์ฑ ์ ์ฉ๋๋ค.
ํด๋์ค ์ด๋ฆ์ ๋ง๋ค์ง ์์๋ ๋ง์ง๋ง ํด๋์ค์ ์ ์ฉ๋๋ค.
.box .div:last-child{}

- .box div{float:left;}
.box{overflow:hidden;} -> float์ ๋ถ๋ชจ ์ด๊ธฐํ- calc((100% - ์ฌ๋ฐฑpx) / ๊ฐ์))
- calc(50% - 5px); - 1/2๋ก ๋ฐ์ค ๋๋๊ธฐ
- div{margin-right:10px;}
div:lastchild{margin-right:0;}- .box$*2
- .div*3{$}

- position:fixed;
top:0; left:0; ์ผ์ชฝ์ ๊ณ ์ (๋ธ๋ผ์ฐ์ ์ํฅx / ์,์ข0์์์น)- main > div{margin-bottom:10px;}
main์๋ ์ง๊ณ div(.box1~7)๋ง ์ ํํ์ฌ ์๋ ์ฌ๋ฐฑ 10px ๋ถ์ฌ- 2๋ฑ๋ถ์ ํ ๋ ๊ผญ calc์์ 100%์์ ๋นผ๋ ๊ฒ์ด ์๋ ์ฃผ์ด์ง %์์ ์ฌ๋ฐฑpx๊ฐ์ ๋นผ์ค๋ค.
.box6 div{ float: left; width: calc(30% - 5px); background: #f00; height:70px; } .box6 div:last-child{ float: right; width: calc(70% - 5px); }
- m10-10-10-160 -> margin: 10px 10px 10px 160px;
๐ก
psf - position: fixed๋ ๊ฐ๋ก์ธ๋ก ๊ฐ๊ณผ ์ขํ๊ฐ ๊ผญ ์จ์ค์ผํจ ์๊ทธ๋ผ ๋ฐ๋ ค๋๋ค.
position: fixed์์ ๋ถ๋ชจ๋์ด๊ฐ์ด ๊ผญ ์์ด์ผ h100%๋ฅผ ์ธ์์์.
BUT
์ฌ๊ธฐ์ ๊ธฐ์ค์ด ๋ธ๋ผ์ฐ์ ๊ธฐ ๋๋ฌธ์ ๋ถ๋ชจ๋์ด ๊ฐ์ด ์์ด๋ ์ฌ์ฉ๊ฐ๋ฅ
์ง๊ณ ์ ํ์๋ฅผ ์ฌ์ฉํ์ง ์๊ณ ์์์ ํ์๋ฅผ ์ ํํ์ฌ ๋ชจ๋ div๊ฐ
margin-bottom:10px;์ ๋จน์๋ค.
- main div{margin-bottom:10px;}

๊ธฐ๋ณธ ์ด๊ธฐํ
- {font:inherit;} - ๊ธ์จ์ฒด ์ด๊ธฐํ
- body {line-height:1;} - ํ๊ฐ๊ฒฉ1
- ul {list-style:none;} - ul ๊ธฐํธ ์ญ์
- a {color: inherit; text-decoration: none;}
{color:inherit;} - ๊ธ์จ ์์ ์ด๊ธฐํ
{text-decoration : none;} - ๋ฐ์ค ์์ฐ- img {vertical-align : top;}
์ด๋ฏธ์ง ์๋ ๊ณต๋ฐฑ ์์ ๊ธฐ์ด๋ฏธ์ง ์๋ก ์ ๋ ฌ
- {margin : 0 auto;} - ๋ธ๋ก๋ ๋ฒจ์ ๊ฐ์ด๋ฐ ์ ๋ ฌํด์ค๋
- {transform : translate(-50%,-50%)}
top-left corner๊ธฐ์ค์ผ๋ก ์ ๊ฐ์ด๋ฐ ์์น์ํค๊ธฐ ์ํด transform์์ฑ์ ์ด์ฉํด x,y์ถ์ผ๋ก ๊ฐ๊ฐ -50%์ฉ ๋ถ์ฌํ์ฌ ์ ๊ฐ์ด๋ฐ ์์นheader .logo{ width: 100px;height: 50px; background: #f00; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); }
- text-align:center; - ๊ธ์ ๊ฐ์ด๋ฐ ์ ๋ ฌ
- border-radius : % - %๋งํผ ๋ชจ์๋ฆฌ ๋ฅ๊ธ๊ฒ
- object-fit : cover; - ์ด๋ฏธ์ง ๋น์จ์ ๋ง๊ฒ ์กฐ์
- ์ด๋ฏธ์ง๋ ์๋ ๊ฐ์ง ์ฌ์ด์ฆ๊ฐ ์๊ธฐ๋๋ฌธ์
w100%์ผ๋ก ์ฌ์ด์ฆ ์ค์ผํ๋ค.
-> ์๊ทธ๋ฌ๋ฉด ์ง๋ฉ๋๋ก ์ฌ์ด์ฆ ์๋ฆฌ๊ณ ๋ ์ด์์ ๊นจ์ง
-> padding์ ๋ค์ ๋ฐฑ๊ทธ๋ผ์ด๋์ ์ด๋ฏธ์ง๊ฐ ๋ณด์กด๋์ด์ผํ ๋
-> margin์ ์๊ด์์ด ๋ฐ์ด์ผํ ๋

main{ width: 800px; margin: 10px auto;} /* margin์ผ๋ก ๊ฐ์ด๋ฐ ์ ๋ ฌ 10px๋ก ์ํ ๋์ฐ๊ธฐ*/ .ht_area h1{ position: absolute; top: 50%;left: 50%; transform: translate(-50%, -50%); width: 150px;height: 50px; background: #f00; } /*๊ฐ์ด๋ฐ ์ ๋ ฌ*/ .ht_area h1 a{ display: block; height: 100%; } .top_area .left li{ float: left; width: calc((100% - 20px) / 3); height: 100px; background: #ff0; margin-right: 10px; } /*calc๋ก ์ฌ๋ฐฑ 20px์ ๋นผ๊ณ 3๋ฑ๋ถ(margin-right)*/ .top_area .left li:nth-child(3n){margin-right: 0;} .top_area .left li:nth-child(-n+3){margin-bottom: 10px;} .bot_area li+li{ margin-top: 10px;} .bot_area img{ width: 150px;height: 150px; object-fit: cover; float: left; } .bot_area p{ width: calc(100% - 160px); height: 150px; background: #ff0; float: right; } /*160px์ธ ์ด์ ๋? ํจ๋ฉ๊ฐ10px์ ํฌํจํ ๊ฐ*/
- a{ display: block; height: 100%; }
-> a ํ๊ทธ๋ ๋์ด๊ฐ์ ์ค์ผํ๋ค.- nth-child (-n+3) - 3์ดํ๋ง ์ ํ
nth-child (n+3) - 3์ด์๋ง ์ ํ- ์๋ฐ ์ ํ์
.bot_areali+li{ margin-top: 10px;}
์ฒซ ๋ฒ์งธ li๋ฅผ ์ ์ธํ๊ณ margin top 10px์ ์ ์ฉํ๋ผ
inline๋ ๋ฒจ์position,float๋ญ ํ๋๋ผ๋ ๋ค์ด๊ฐ๋ฉด ๊พธ๋ฏธ๊ธฐ ๊ฐ๋ฅ(๋์ด)ํ๋ค
-> ์๋๋display: block;์ค์ผํจ
-> width,height,line-heightinline-block,inline์์ฑ๋ค์ ๊ทธ๋ฅ ํ ์คํธ๋ผ ์๊ฐํ๋ฉด ํธํจinline,inline-block,img๋ค์ ๋ฐ์ ์์ ์ฌ๋ฐฑ์์
๊ณต๋ฐฑ์ ์์จ๋??
->vertical-align

.bot_area img{ width: 150px;height: 150px; object-fit: cover; float: left; } .bot_area p{ width: calc(100% - 160px); background: #ff0; float: right; }
- ๋ถ๋ชจ์ ํฌํจ ๋ ๋ค๋ฅธ ์์์ด ๋์ด๋ฅผ ๊ฐ์ง๊ณ ์๋ค๊ณ ๋๋จธ์ง ์์์ด ์๋์ผ๋ก ๋์ด๋ฅผ ๊ฐ๋ ๊ฒ์ด ์๋๋ค.
-> ๋์ด ๊ฐ์ฃผ๊ธฐ

<div class="visual"> <div>1</div> <div class="slide"> 2 <a href=""class= "btn prev1">์ด์ </a> <a href=""class= "btn prev2">๋ค์</a> </div> </div> /* ์ด์ ,๋ค์๋ฒํผ์ aํ๊ทธ ์ถ์ฒ*/
<section class="box1"> <div class="wap"> <div class="list list01"> <div>70%</div> <div>30%</div> </div> <div class="list list02"> <div>30%</div> <div>70%</div> </div> </div> </section>.box1 .list{overflow: hidden;} .box1 .list div{float: left; height: 100px;background: #f00;} .box1 .list div:last-child{float: right;} .box1 .list01{margin-bottom: 10px;} .box1 .list01 div{width: calc(70% - 5px);} .box1 .list01 div:last-child{width: calc(30% - 5px);} .box1 .list02 div{width: calc(30% - 5px);} .box1 .list02 div:last-child{width: calc(70% - 5px);}
- ๊ณตํต๋ถ๋ชจ๋ก ํ๋ฒ์ ์ฝ๋ฉ์ ํด์ฃผ๋๊ฒ ์ข๋ค