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

๐Ÿ’ซ ๋ฐฐ๊ฒฝ ๊ด€๋ จ CSS ์†์„ฑ๋“ค

.main-background {
  background-image : url(../img/shoes.jpg);
  background-size : cover;
  background-repeat : no-repeat;
  background-position : center;
  background-attachment : fixed;
}

cover : ๋ฐฐ๊ฒฝ์œผ๋กœ ๊ฝ‰ ์ฑ„์›Œ์ฃผ์„ธ์š”
contain : ๋ฐฐ๊ฒฝ์ด ์ž˜๋ฆฌ์ง€ ์•Š๊ฒŒ ๊ฝ‰ ์ฑ„์›Œ์ฃผ์„ธ์š”
background-attachment : ์›น์‚ฌ์ดํŠธ๊ฐ€ ์Šคํฌ๋กค ๋  ๋•Œ ๋ฐฐ๊ฒฝ์ด ์‹ ๊ธฐํ•˜๊ฒŒ ๋™์ž‘ํ•˜๊ฒŒ ๋งŒ๋“ค๊ณ  ์‹ถ์œผ๋ฉด ์‚ฌ์šฉํ•ด๋ณด๊ธฐ
ย 

๐Ÿ’ซ ๋ฐฐ๊ฒฝ ๋‘ ๊ฐœ ๊ฒน์น˜๊ธฐ

.main-background {
  background-image : url(../img/shoes.jpg), url(person.jpg);
}

์ฝค๋งˆ๋กœ ์ด๋ฏธ์ง€ ๋‘๊ฐœ ์ฒจ๋ถ€ ๊ฐ€๋Šฅ
ย 

๐Ÿ’ซ ๋ฐฐ๊ฒฝ์— ๊ฒ€์€์ƒ‰ ํ‹ดํŠธ ์ฃผ๊ธฐ

.main-background {
  background-image: linear-gradient( rgba(0,0,0,0.5), rgba(0,0,0,0.5) ), url(์ด๋ฏธ์ง€๊ฒฝ๋กœ~~) ;
}

linear-gradient : ์ƒ‰์ด ์ ์ง„์ ์œผ๋กœ ๋ณ€ํ•˜๋Š” gradient๋ฅผ ์ค„ ์ˆ˜ ์žˆ๋Š” ํ‚ค์›Œ๋“œ
ํˆฌ๋ช…๋„ 0.5์˜ ๊ฒ€์€์ƒ‰์„ ์ž…ํžŒ ํ›„, ๋ฐฐ๊ฒฝ ๊ฒน์น˜๊ธฐ ์‚ฌ์šฉ
ย 

๐Ÿ’ซ ์ฃผ์˜ํ•ด์•ผํ•  margin ๋ฒ„๊ทธ

margin collapse effect ๋ผ๊ณ  ๋ถ€๋ฅด๋Š” ์ผ์ข…์˜ ๋ฒ„๊ทธ
์›๋ž˜ ๋ฐ•์Šค๋“ค์˜ ํ…Œ๋‘๋ฆฌ๊ฐ€ ๋งŒ๋‚˜๋ฉด margin์ด ํ•ฉ์ณ์ง. (๋ฐ•์Šค๊ฐ€ ๋‚ด๋ถ€์—์„œ ๋งŒ๋‚˜๋“  ์™ธ๋ถ€์—์„œ ๋งŒ๋‚˜๋“  ์ƒ๊ด€X)
1. ๋งˆ์ง„์„ ํ•˜๋‚˜๋กœ ํ•ฉ์ณ์ฃผ๊ณ 
2. ํ˜น์—ฌ๋‚˜ ๋‘˜ ๋‹ค ๋งˆ์ง„์ด ์žˆ์œผ๋ฉด ๋‘˜ ์ค‘์— ๋” ํฐ ๋งˆ์ง„์„ ํ•˜๋‚˜๋งŒ ์ ์šฉ.
๊ทธ๋ž˜์„œ ๋‘ ๋ฐ•์Šค์˜ ํ…Œ๋‘๋ฆฌ๊ฐ€ย ๊ฒน์น˜์ง€ ์•Š๋„๋กย ํ•˜๋ฉด ๋ณด๋‹ค ๋” ์ •ํ™•ํ•œ ๋งˆ์ง„์„ ์ค„ ์ˆ˜ ์žˆ๋‹ค.
โ†’ ๋ถ€๋ชจ ๋ฐ•์Šค์— padding์„ 1px ์ด๋ ‡๊ฒŒ ์กฐ๊ธˆ ์ฃผ๋Š” ๊ฒƒ์œผ๋กœ ์‰ฝ๊ฒŒ ํ•ด๊ฒฐ

ย 

๐Ÿ’ซ ์˜ค๋Š˜์˜ ์ˆ™์ œ : ์ œ๋ชฉ ๋ฐ‘์— ๊ธ€ ๋„ฃ๊ณ  ๋ฒ„ํŠผ ํ•˜๋‚˜๋งŒ ์ด์˜๊ฒŒ ๋„ฃ์–ด์˜ค๊ธฐ.

  • HTML
<!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>
</body>
</html>
  • main.css
.main-background{
    width: 100%;
    height: 500px;
    background-image: url(../img/shoes.jpg);
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    padding: 1px;

}

.main-title{
    color: white;
    font-size: 40px;
    margin-top: 250px;
    margin-left : 40%;
    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;
    margin-left : 43%;
    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;
    margin-left : 45%;
    border: none;
    font-family: 'Oneprettynight';
}

.main-background button:hover {
    margin-top: 5px;
    margin-bottom: 5px;
    box-shadow: 0px 0px 0px 0px #68628a;
}
  • font.css
/* ์›น ํฐํŠธ */
@font-face {
    font-family: 'Oneprettynight';
    src: url('https://fastly.jsdelivr.net/gh/projectnoonnu/noonfonts_twelve@1.1/Cafe24Oneprettynight.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'SupermagicB';
    src: url('https://fastly.jsdelivr.net/gh/projectnoonnu/noonfonts_2307-2@1.0/Cafe24Supermagic-Bold-v1.0.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
}

@font-face {
    font-family: 'Shiningstar';
    src: url('https://fastly.jsdelivr.net/gh/projectnoonnu/noonfonts_twelve@1.1/Cafe24Shiningstar.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

/* ๋กœ์ปฌ ํฐํŠธ */
@font-face {
    font-family: 'OhsquareAir';
    src: url('font/Cafe24OhsquareAir-v2.0.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'MeongiB';
    src: url('font/Cafe24Meongi-B-v1.0.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'MeongiW';
    src: url('font/Cafe24Meongi-W-v1.0.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

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

ํฐํŠธ๋ฅผ ์ ์šฉํ•˜๋ฉด์„œ ์ฒ˜์Œ์— ์ ์šฉ์ด ์•ˆ๋ผ์„œ ์˜ค๋ž˜ ๊ฑธ๋ ธ์—ˆ๋‹ค.
css ๋‚ด์—์„œ ๋‹ค๋ฅธ css๋ฅผ ์‚ฌ์šฉํ•˜๋ ค๋ฉด ์„ ์–ธ์„ ํ•ด์ค˜์•ผ ํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹Œ๊ฐ€? ํ–ˆ์—ˆ๋Š”๋ฐ HTML ์†Œ์Šค์— link๋ฅผ ํ•ด์ฃผ๋‹ˆ ํ•ด๊ฒฐ๋œ๋‹ค๋Š” ๊ฒƒ์„ ์•Œ๊ฒŒ ๋˜์—ˆ๋‹ค.
๋ฒ„ํŠผ์˜ ๊ฒฝ์šฐ ๋ธ”๋กœ๊ทธ๋ฅผ ์ฐพ์•„์„œ ์‚ฌ์šฉํ–ˆ๋Š”๋ฐ ๋ธ”๋กœ๊ทธ์—์„œ ๋ณธ ๊ฒƒ๊ณผ ๋‹ค๋ฅด๊ฒŒ ๋ฒ„ํŠผ์— ๊ฒ€์ •์ƒ‰ ํ…Œ๋‘๋ฆฌ๊ฐ€ ์ƒ๊ฒผ์—ˆ๋‹ค.
border: none ์„ ํ•ด์ฃผ๋‹ˆ ๊ฒ€์ •์ƒ‰ ํ…Œ๋‘๋ฆฌ๊ฐ€ ์‚ฌ๋ผ์กŒ๋‹ค.

By Dozzing

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

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