๐ŸณCoding apple HTML/CSS All-in-one : ๊ธฐ์ดˆ๋ถ€ํ„ฐ Bootstrap, SASS, ๊ณ ๊ธ‰ animation ๊นŒ์ง€ ๊ฐ•์˜๋ฅผ ๋ณด๊ณ  ์ •๋ฆฌํ•œ ๊ธ€์ž…๋‹ˆ๋‹ค ๐Ÿณ

๐Ÿ’ซ position ์†์„ฑ

.box {
  position : static; /* ๊ธฐ์ค€ X (์ขŒํ‘œ์ ์šฉ X) */
  position : relative; /* ๋‚ด ์›๋ž˜ ์œ„์น˜ ๊ธฐ์ค€ */
  position : absolute; /* ๋ถ€๋ชจ ์ค‘ position : relative๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๋ถ€๋ชจ ๊ธฐ์ค€ */
  position : fixed; /* ๋ธŒ๋ผ์šฐ์ € ์ฐฝ ๊ธฐ์ค€ (viewport) */
}

์ขŒํ‘œ ์†์„ฑ์„ ์ ์šฉํ• ย ๊ธฐ์ค€์ ์ด ์—ฌ๊ธฐ์—์š”~! ๋ผ๊ณ  ์ง€์ •ํ•ด์ฃผ๋Š” ์—ญํ• 

ย 

๐Ÿ’ซ ์ขŒํ‘œ ์†์„ฑ

.box {
  top : 20px;
  left : 30%;
}

top, left, bottom, right ๋ผ๋Š” ์†์„ฑ์„ ์‚ฌ์šฉํ•˜๋ฉด ์š”์†Œ์˜ ์ƒํ•˜์ขŒ์šฐ ์œ„์น˜๋ฅผ ๋ณ€๊ฒฝ ๊ฐ€๋Šฅ

ย 

๐Ÿ’ซ position : absolute ๋ฅผ ์ ์šฉํ•œ ์š”์†Œ ๊ฐ€์šด๋ฐ ์ •๋ ฌ

.button {
  position : absolute; 
  left : 0;
  right : 0; 
  margin-left : auto;
  margin-right : auto;
  width : ์ ์ ˆํžˆ
}

ย 

๐Ÿ’ซ ์˜ค๋Š˜์˜ ์ˆ™์ œ : ๋ฐฐ๊ฒฝ ์œ„์— ํšŒ์ƒ‰ ๋ฐ•์Šค๊ฐ€ ๊ฒน์น˜๊ฒŒ ๋งŒ๋“ค๊ธฐ

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link href="css/main.css" rel="stylesheet">
    <link href="css/font.css" rel="stylesheet">
</head>
<body>
    <div class="main-background">
        <h4 class="main-title">Buy Our Shoes</h4>
        <p>์˜ˆ์œ ์‹ ๋ฐœ ์‚ฌ๋Ÿฌ ์˜ค์„ธ์š”๐Ÿ’•</p>
        <button>๋ณด๋Ÿฌ๊ฐ€๊ธฐ</button>
        <div class="background"></div>
    </div>
</body>
</html>
.main-background{
    width: 100%;
    height: 500px;
    background-image: url(../img/shoes.jpg);
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    padding: 1px;
    position: relative;
}

.main-title{
    color: white;
    font-size: 40px;
    text-align: center;
    font-family: 'MeongiW';
}

.main-background p{
    color: white;
    font-size: 20px;
    text-shadow: -2px 0px black, 0px 2px black, 2px 0px black, 0px -2px black;
    text-align: center;
    font-family: 'Oneprettynight';
}

.main-background button{
    width: 100px;
    font-size: 500;
    font-weight: 600;
    text-align: center;
    line-height: 50px;
    color: #FFF;
    border-radius: 5px;
    transition: all 0.2s;
    background: #b3aaee;
    box-shadow: 0px 5px 0px 0px #68628a;
    border: none;
    font-family: 'Oneprettynight';
    margin-left : 47%;
}

.main-background button:hover {
    margin-top: 5px;
    margin-bottom: 5px;
    box-shadow: 0px 0px 0px 0px #68628a;
}

.background{
    width: 50%;
    height: 300px;
    background-color: gray;
    position: absolute;
    left : 0;
    right : 0; 
    margin-left : auto;
    margin-right : auto;
    bottom: -100px;
}

โญ ์–ด๋ ค์› ๋˜ ๊ฒƒ๋“ค

๋ฒ„ํŠผ์„ hover ๋ฅผ ์ค˜์„œ ๋งˆ์šฐ์Šค๋ฅผ ๋ฒ„ํŠผ์— ์˜ฌ๋ฆด ๋•Œ๋งˆ๋‹ค ํšŒ์ƒ‰ div๊ฐ€ ๊ฐ™์ด ๋‚ด๋ ค๊ฐ”์—ˆ๋‹ค
๋ฉ”์ธ div์— position : relative ๋ฅผ ํ•ด์ฃผ๊ณ , ํšŒ์ƒ‰ div์— position : absolute ๋ฅผ ํ•ด์„œ ํšŒ์ƒ‰ div๋ฅผ ๋„์›Œ์„œ ๊ฐ™์ด ๋‚ด๋ ค๊ฐ€์ง€ ์•Š๋„๋ก ๋งŒ๋“ค์—ˆ๋‹ค.

By Dozzing

๋‹ต๊ธ€ ๋‚จ๊ธฐ๊ธฐ

์ด๋ฉ”์ผ ์ฃผ์†Œ๋Š” ๊ณต๊ฐœ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ํ•„์ˆ˜ ํ•„๋“œ๋Š” *๋กœ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค