λ³λμ νλ μμν¬λ λΌμ΄λΈλ¬λ¦¬ κ°μ
μΉκ°λ°μ λμμ£Όλ λͺ¨λμ μ¬μ©νμ§ μκ³
μμν HTMLκ³Ό CSSλ§ μ¬μ©νμ¬
μ€λ²μμΉ μμ
μ ν νμ΄μ§λ₯Ό λ§λλ μ€μ΅μ μ§νν΄λ³΄μλ€.
νμμ μκ·Έλλ μ€λ²μμΉλ₯Ό μ’μν΄μ
λ§λ€κ³ λλ κ΄ν μ§λ¦Ώνλ€ γ
γ
λ΄ μ΅μ μΊλ¦ν°λ 루μμ° μ΄μ§λ‘± πΈ♥
μΆμ²: https://github.com/ParkYoungWoong/overwatch-hero-selector-vanilla
GitHub - ParkYoungWoong/overwatch-hero-selector-vanilla
Contribute to ParkYoungWoong/overwatch-hero-selector-vanilla development by creating an account on GitHub.
github.com
index.html μ½λ
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Overwatch Heroes</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/reset-css@5.0.1/reset.min.css" />
<link rel="stylesheet" href="./main.css" />
</head>
<body>
<div class="container">
<div class="heroes">
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
<div class="hero">
<div class="image"></div>
</div>
</div>
<div class="logo">
<img src="./images/logo_overwatch.png" alt="Overwatch">
</div>
</div>
</body>
</html>
main.css μ½λ
body {
height: 100vh; /* λ·°ν¬νΈμ λμ΄ 100%λ‘ μ€μ */
background-image: url(./images/bg.jpg);
background-size: cover; /* λ λμ λλΉμ λ§κ² λ°°κ²½ μ΄λ―Έμ§ μΆλ ₯ */
background-repeat: no-repeat; /* λ°°κ²½ μ΄λ―Έμ§ λ°λ³΅ ν΄μ */
background-attachment: fixed; /* λ°°κ²½ μ΄λ―Έμ§λ μ€ν¬λ‘€λμ§ μλλ‘ λ·°ν¬νΈμ κ³ μ */
}
.container {
padding: 50px 0; /* container μμλ λ΄λΆ μ¬λ°± μ€μ */
}
.container .heroes {
display: flex; /* heroes μμλ€ μν μ λ ¬ */
flex-wrap: wrap; /* μ€λ°κΏ */
justify-content: center; /* heroλ€ κ°μ΄λ° μ λ ¬ */
max-width: 700px; /* μ΅λ λλΉ μ€μ , κ·Έ μ΄νλ μλ μ λ ¬ */
margin: 0 auto; /* μ’μ° μ¬λ°± μλ μ€μ (κ°μ΄λ° μ λ ¬λ¨) */
padding: 40px 20px; /* heroes μμ λ΄λΆ μ¬λ°± μ€μ */
}
.container .heroes .hero {
width: 80px;
height: 84px;
margin: 4px; /* μ’μ°μν μ¬λ°± 4pxλ‘ μ€μ */
border: 3px solid #fff; /* hero ν°μ ν
λ리 μ */
border-radius: 10px; /* λͺ¨μ리 λ₯κΈκ² */
box-sizing: border-box; /* border μ€μ μΌλ‘ μΈν΄ μ»€μ§ μμ μ€μ¬μ£ΌκΈ° */
background-color: #555;
overflow: hidden; /* hero image λμΉλ μμ μλΌλ΄κΈ° */
transform: skewX(-14deg); /* -14λλ§νΌ κΈ°μΈμ */
transition: /* μμ±λ³λ‘ μ ν duration λ°λ‘ μ€μ */
transform .1s, /* 컀μ§λ ν¨κ³Ό */
background-color .6s; /* λ°°κ²½μ μ ν ν¨κ³Ό μ’ λ λλ¦¬κ² */
}
.container .heroes .hero:hover { /* heroμ λ§μ°μ€ μ¬λ¦¬λ©΄ */
background-color: orange; /* λ°°κ²½ μμ orangeλ‘ λ°λ */
transform: skewX(-14deg) scale(1.3); /* μμ -14λ κΈ°μΈμ¬μ§μ±λ‘ 1.3λ°° μ»€μ§ */
z-index: 1; /* μμ μμ μμ μ‘°μ */
}
.container .heroes .hero .image {
width: 140%; /* λΆλͺ¨ μμμΈ hero λλΉμμ μλ ν¬κΈ°(%) */
height: 100%;
background-position: center; /* μ΄λ―Έμ§ κ°μ΄λ° λ°°μΉ */
background-repeat: no-repeat; /* μ΄λ―Έμ§ λ°λ³΅ ν΄μ */
background-size: 90px; /* κ°λ‘ λλΉ */
transform: skewX(14deg) translateX(-16px); /* 14λ κΈ°μΈμ¬μ€ λ§νΌ κ±°κΎΈλ‘ κΈ°μΈμ΄κΈ°, xμΆ λ°©ν₯μΌλ‘ -16px λ§νΌ μ΄λ */
}
/* μ΄ 32λͺ
μ hero μ΄λ―Έμ§ κ°μ Έμ€κΈ° */
.container .heroes .hero:nth-child(1) .image { background-image: url(./images/hero1.png);}
.container .heroes .hero:nth-child(2) .image { background-image: url(./images/hero2.png);}
.container .heroes .hero:nth-child(3) .image { background-image: url(./images/hero3.png);}
.container .heroes .hero:nth-child(4) .image { background-image: url(./images/hero4.png);}
.container .heroes .hero:nth-child(5) .image { background-image: url(./images/hero5.png);}
.container .heroes .hero:nth-child(6) .image { background-image: url(./images/hero6.png);}
.container .heroes .hero:nth-child(7) .image { background-image: url(./images/hero7.png);}
.container .heroes .hero:nth-child(8) .image { background-image: url(./images/hero8.png);}
.container .heroes .hero:nth-child(9) .image { background-image: url(./images/hero9.png);}
.container .heroes .hero:nth-child(10) .image { background-image: url(./images/hero10.png);}
.container .heroes .hero:nth-child(11) .image { background-image: url(./images/hero11.png);}
.container .heroes .hero:nth-child(12) .image { background-image: url(./images/hero12.png);}
.container .heroes .hero:nth-child(13) .image { background-image: url(./images/hero13.png);}
.container .heroes .hero:nth-child(14) .image { background-image: url(./images/hero14.png);}
.container .heroes .hero:nth-child(15) .image { background-image: url(./images/hero15.png);}
.container .heroes .hero:nth-child(16) .image { background-image: url(./images/hero16.png);}
.container .heroes .hero:nth-child(17) .image { background-image: url(./images/hero17.png);}
.container .heroes .hero:nth-child(18) .image { background-image: url(./images/hero18.png);}
.container .heroes .hero:nth-child(19) .image { background-image: url(./images/hero19.png);}
.container .heroes .hero:nth-child(20) .image { background-image: url(./images/hero20.png);}
.container .heroes .hero:nth-child(21) .image { background-image: url(./images/hero21.png);}
.container .heroes .hero:nth-child(22) .image { background-image: url(./images/hero22.png);}
.container .heroes .hero:nth-child(23) .image { background-image: url(./images/hero23.png);}
.container .heroes .hero:nth-child(24) .image { background-image: url(./images/hero24.png);}
.container .heroes .hero:nth-child(25) .image { background-image: url(./images/hero25.png);}
.container .heroes .hero:nth-child(26) .image { background-image: url(./images/hero26.png);}
.container .heroes .hero:nth-child(27) .image { background-image: url(./images/hero27.png);}
.container .heroes .hero:nth-child(28) .image { background-image: url(./images/hero28.png);}
.container .heroes .hero:nth-child(29) .image { background-image: url(./images/hero29.png);}
.container .heroes .hero:nth-child(30) .image { background-image: url(./images/hero30.png);}
.container .heroes .hero:nth-child(31) .image { background-image: url(./images/hero31.png);}
.container .heroes .hero:nth-child(32) .image { background-image: url(./images/hero32.png);}
.container .logo {
max-width: 300px; /* logo μ΅λ λλΉ μ€μ */
margin: 0 auto; /* μ’μ° μ¬λ°± autoλ‘ μ€μ (κ°μ΄λ°λ‘ μ λ ¬λ¨) */
padding: 0 20px; /* logo μ’μ°μλ§ λ΄λΆ μ¬λ°± μ€μ */
}
.container .logo img {
width: 100%; /* logoμ 300pxλ³΄λ€ μ»€μ§ μ μμ */
}
ΰ· μ΅μ’ μμ±λ νμ΄μ§ ΰ·
μ§κΈμ vanilla λ²μ μ΄κΈ°μ
32κ°μ μ΄λ―Έμ§λ₯Ό λΆλ¬μ€λ μ½λλ₯Ό λͺ¨λ
μμ±ν΄μ€μΌνλ λΆνΈν¨μ΄ μ‘΄μ¬νλ€.
μ΄λ₯Ό 보μνκΈ° μν΄μλ SCSSλΌλ
CSS μ μ²λ¦¬κΈ°λ₯Ό μ¬μ©νλ€λ©΄
λ³΄λ€ μμνκ² μ½λλ₯Ό μμ±ν μ μκ² λ κ²μ΄λ€.
λ€μμ SCSS 곡λΆν΄ μμ μ μ©μμΌλ΄μΌμ§-!!
β§Ω©(Λ ωΛ*)Ωβ§
λκΈ