[๐Ÿ’ป] 1์ฃผ์ฐจ ์ •๋ฆฌ

J-silverยท2022๋…„ 8์›” 25์ผ

web-project

๋ชฉ๋ก ๋ณด๊ธฐ
3/18
  • style์€ ํ—ค๋”์— ์ฃผ๋กœ ์“ฐ์ด๊ธดํ•˜์ง€๋งŒ
    ๋ฐ”๋””์•ˆ, ์–ด๋””๋“  ์ƒ๊ด€์—†์Œ
    -> ์ œ์ผ ์ข‹์€ ๋ฐฉ๋ฒ•์€ style ํŒŒ์ผ์„ ๋งŒ๋“ค์–ด์„œ ์—ฐ๊ฒฐํ•ด ์ฃผ๋Š”๊ฒƒ!



์ƒˆ๋กœ์šด ๊ฐœ๋…

โœ calc

๊ด„ํ˜ธ ์•ˆ์˜ ์‹ ์‚ฌ์น™์—ฐ์‚ฐ
width, height, margin, padding๋“ฑ๋“ฑ ๊ฐ€๋Šฅ

ํŠน์ง•

๊ฐ’์„ ๊ณ„์‚ฐํ•˜๊ธฐ ์–ด๋ ค์šธ๋•Œ ํŽธํ•˜๊ฒŒ ๊ณ„์‚ฐํ•ด์ค€๋‹ค!
๋ฐ˜์‘ํ˜•์ฒ˜๋Ÿผ ๋ธŒ๋ผ์šฐ์ € ํฌ๊ธฐ์— ๋”ฐ๋ผ ์š”์†Œ์˜ ๋„ˆ๋น„์™€ ๋†’์ด๊ฐ€ ๋ณ€ํ™”ํ•ด์•ผํ•˜๋Š” ๊ฒฝ์šฐ ์‚ฌ์šฉ

width : clac(100% / 3) - w100% ๋ฅผ 3๋“ฑ๋ถ„ ์‹œํ‚จ๋‹ค.
width : clac((100% - px) / 3) - w100% -px๋บ€ w๋ฅผ 3๋“ฑ๋ถ„ํ•œ๋‹ค.

โ— ์•ž๋’ค๋กœ ๋„์–ด์“ฐ๊ธฐ ์œ ์˜
โ— calc ์ŠคํŽ ๋ง ์œ ์˜


์ •๋ ฌํ•˜๋Š” ์• ๋“ค

์š”์†Œ์˜ ์œ„์น˜๋ฅผ ์žก์•„์ฃผ๋Š”๊ฒƒ
๊ตฌ์กฐ์งค๋•Œ ์ œ์ผ ์ค‘์š”

1. โœ position

*ํŠน์ด์  - ์ƒ์† ์•ˆ๋จ (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


2. โœ float

ํ•˜๋Š˜๋กœ ๋„์–ด์„œ ์ •๋ ฌ์‹œ์ผœ์ค€๋‹ค.
position๋ณด๋‹จ ๋‚ฎ๊ฒŒ ๋– ์žˆ๋‹ค.
๋ฐ”๋””์— ์ „๋ฐ˜์ ์ธ ๋ฐฐ๊ฒฝ์ƒ‰์„ ๋„ฃ๋Š”๊ฑฐ๋‹ค.

์‚ฌ๋ฐฉ๊ฐ’

left, right

๐Ÿ”‘์ดˆ๊ธฐํ™” / ํ•ด์ œ ํ•˜๋Š”๋ฒ•

float:left/right -> overflow:hidden


3. โœ margin:0 auto;

whith๊ฐ€ ์žˆ๋Š” ์˜์—ญ ์ค‘์•™์ •๋ ฌ
์ฃผ๋กœ ํฐ์˜์—ญ์˜ ๊ธฐ์ค€์„ ์žก์„๋•Œ ์“ฐ์ž„

โœ ์™•๋”ฐ ์„ ํƒ์ž

์ธ์ •์š”์†Œ 1๋ฒˆ๋นผ๊ณ  2,3,4๋งŒ ์ ์šฉ๋œ๋‹ค. 1๋ฒˆ์€ ์™•๋”ฐ

.bottom-area li+li{}

-> ์ฒซ๋ฒˆ์งธ li๋Š” ์ œ์™ธํ•˜๊ณ , 2๋ฒˆ์งธ li๋ถ€ํ„ฐ ์†์„ฑ ์ ์šฉ๋œ๋‹ค.


โœ ๊ฐ€์ƒ ์„ ํƒ์ž

last-child

ํด๋ž˜์Šค ์ด๋ฆ„์„ ๋งŒ๋“ค์ง€ ์•Š์•„๋„ ๋งˆ์ง€๋ง‰ ํด๋ž˜์Šค์— ์ ์šฉ๋œ๋‹ค.

.box .div:last-child{}







float ์‹ค์Šต


๐Ÿ“ ์ฃผ์š” ํŠน์ง•

  • .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_area li+li{ margin-top: 10px;}
    ์ฒซ ๋ฒˆ์งธ li๋ฅผ ์ œ์™ธํ•˜๊ณ  margin top 10px์„ ์ ์šฉํ•˜๋ผ

๐Ÿ’ก inline -block

  • inline๋ ˆ๋ฒจ์€ position,float ๋ญ ํ•˜๋‚˜๋ผ๋„ ๋“ค์–ด๊ฐ€๋ฉด ๊พธ๋ฏธ๊ธฐ ๊ฐ€๋Šฅ(๋†’์ด)ํ•˜๋‹ค
    -> ์›๋ž˜๋Š” display: block;์ค˜์•ผํ•จ
    -> width,height,line-height
  • inline-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);}
  • ๊ณตํ†ต๋ถ„๋ชจ๋กœ ํ•œ๋ฒˆ์— ์ฝ”๋”ฉ์„ ํ•ด์ฃผ๋Š”๊ฒŒ ์ข‹๋‹ค

๐Ÿ’ก text ์ถ”์ฒœ ํƒœ๊ทธ

em - ๋‹จ์–ด๊ฐ•์กฐ

strong โ€“ ๋ฌธ์žฅ๊ฐ•์กฐ, ๋‚ด์šฉ๊ณผ ์ œ๋ชฉ์žˆ์„๋•Œ ๊ฐ•์กฐ, ์ œ๋ชฉ


๐Ÿ’ก ์˜์—ญ ํƒœ๊ทธ

section-event (sc-event) โ€” ์„น์…˜

event-area โ€” ์˜์—ญ ์žก์•„์ค„๋•Œ

event-wrap โ€” ์ž‘์€ ๋‹จ์œ„

event-box โ€” ๋” ์ž‘์€ ๋‹จ์œ„

profile
๋‹ฌ๋ฆฌ๋Š” ๊ฑฐ๋ถ์ด

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