[Mission 1~3] ๊ตฌํ (ํ์ ๊ตฌํ ์ฌํญ)
โจ ๊ตฌํ ๊ธฐ๊ฐ : 11/22~26
img
ํ๊ทธ๋ฅผ ์ฌ์ฉํ์ฌ ๋ก๊ณ ๋ฅผ ์ด๋ฏธ์ง ํ์ผ๋ก ์ ์div
ํน์ section
ํ๊ทธ๊ฐ ํ์ํฉ๋๋ค.form
ํ๊ทธ๋ฅผ ํ์ฉํด์ฃผ์ธ์.input
ํ๊ทธ๋ฅผ ์ฌ์ฉํ์ฌ ์์ด๋, ๋น๋ฐ๋ฒํธ๋ฅผ ์
๋ ฅํ๋ ์ฐฝ์ ๊ตฌํํด์ฃผ์ธ์.input
์ ํ์
์ ๊ฐ๊ฐ text
ํน์ password
์
๋๋ค.input
์ ์์ฑ์ผ๋ก placeholder
๊ฐ ์์ต๋๋ค. ํด๋น ์์ฑ์ ์ฌ์ฉํ์ฌ "์ ํ๋ฒํธ, ์ฌ์ฉ์ ์ด๋ฆ ๋๋ ์ด๋ฉ์ผ" ๋ฑ์ ๊ฐ์ ๋ฃ์ด์ฃผ์๋ฉด ๋ฉ๋๋ค.button
ํ๊ทธ๋ฅผ ์ฌ์ฉํด์ฃผ์ธ์.[ Result ]
- display: flex ์์ฑ ํ์ฉํ์ฌ body, div, form ์ ๋ ฌ
button {
background-color: #0096f6;
opacity: 0.5; /* ํฌ๋ช
๋ 50% */
}
button.active {
background-color: #0096f6;
opacity: 1; /* ํฌ๋ช
๋ 0% */
}
a
ํ๊ทธ๋ฅผ ์ ์ฉํ๋ฉด ๋ฐ์ค์ด ์๊ธฐ๋๋ฐ ์ด๋ฅผ ์ง์์ฃผ๋ css ์ค์ ์ด๋ค.a {
text-decoration-line: none;
}
[ login.html ]
<form class="loginBox"> <input class="id" type="text" placeholder="์ ํ๋ฒํธ, ์ฌ์ฉ์ ์ด๋ฆ ๋๋ ์ด๋ฉ์ผ"> <input class="pw" type="password" placeholder="๋น๋ฐ๋ฒํธ"> <button class="loginBtn">๋ก๊ทธ์ธ</button> </form>
[ login.css ]
button.active { background-color: #0096f6; opacity: 1; cursor: pointer; font-weight: bold; }
[ login.js ]
- ์ผํญ ์ฐ์ฐ์ ์ฌ์ฉ
- id์ '@' ํฌํจ, pw ๊ธธ์ด 8๊ธ์ ์ด์ : active ์ถ๊ฐ, onclick ์ด๋ฒคํธ ํ์ฑํ
- ์๋ ๊ฒฝ์ฐ : active ์ญ์ , onclick ์ด๋ฒคํธ ๋นํ์ฑํ โ ์ ๋ ฅํ๋ค ์ง์ ์ ๋๋ ๋นํ์ฑํ๋ก ๋ง๋ค์ด์ค.
const loginBox = document.querySelector('.loginBox'); const loginBtn = document.querySelector('.loginBtn'); loginBox.onkeyup = function () { let userId = document.querySelector('.id').value; let userPw = document.querySelector('.pw').value; ((userId.includes('@')) && (userPw.length >= 8)) ? (loginBtn.classList.add('active'), loginBtn.onclick = moveList) : (loginBtn.classList.remove('active'), loginBtn.onclick=null); }; function moveList(e) { e.preventDefault(); window.location.href = "list.html"; }
[ Result ]
์ฃผ์ด์ง ์กฐ๊ฑด์ ๋ง๊ฒ ์
๋ ฅํ์ ๋ ๋ก๊ทธ์ธ ๋ฒํผ ํ์ฑํ ๋๊ณ ๋ฆฌ์คํธ ํ์ด์ง๋ก ๋์ด๊ฐ๋ค. ๊ทธ๋ฌ๋ ์กฐ๊ฑด์ ๋ง๊ฒ ์
๋ ฅํ๋ค ์ง์ ์ ๋๋ ๋ฆฌ์คํธ ํ์ด์ง๋ก ๋์ด๊ฐ๋ ํ์์ด ๋ฐ์ํ๊ณ ์ด๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด ํด๋น ์ด๋ฒคํธ์ธ onclick์ null๋ก ์ค์ ํ์ฌ ํด๋ฆญํ์ ๋ ๋ฐ์ํ๋ ํจ์๋ฅผ ํด์ ํด์คฌ๋ค.
[list.html]
<div class="wrapper"> <div class="img"> <div class="scale"><img src="img/coffee.jpg" alt="ํ ํผ๋ ์ฝ๋ ๋ธ๋ฃจ"></div> <p>ํ ํผ๋ ์ฝ๋ ๋ธ๋ฃจ <i class="far fa-heart"></i></p> </div> <div class="img"> <div class="scale"><img src="img/coffee1.jpg" alt="๋์ดํธ๋ก ๋ฐ๋๋ผ ํฌ๋ฆผ"></div> <p>๋์ดํธ๋ก ๋ฐ๋๋ผ ํฌ๋ฆผ <i class="far fa-heart"></i></p> </div> <div class="img"> <div class="scale"><img src="img/coffee2.jpg" alt="๋์ดํธ๋ก ์ฝ๋ ๋ธ๋ฃจ"></div> <p>๋์ดํธ๋ก ์ฝ๋ ๋ธ๋ฃจ <i class="far fa-heart"></i></p> </div> <div class="img"> <div class="scale"><img src="img/coffee3.jpg" alt="๋์ฒด ์ฝ๋ ๋ธ๋ฃจ"></div> <p>๋์ฒด ์ฝ๋ ๋ธ๋ฃจ <i class="far fa-heart"></i></p> </div> </div>
[list.css]
- ์ ์ฒด๋ฅผ ๊ฐ์ธ๋ div์ flex-wrap ์์ฑ ์ด์ฉํด ๋ฉ๋ด ์ ๋ ฌ
- transform: scale() ์ด์ฉํด ์ด๋ฏธ์ง ํ๋
- ํ๋๋์ด ํ์ด๋๊ฐ๋ ๋ถ๋ถ overflow: hidden์ผ๋ก ์จ๊ฒจ์ฃผ๊ธฐ
- ๋ถ๋๋ฝ๊ฒ ํ๋/์ถ์ ์ํค๊ธฐ ์ํด transition: all ease-in-out ์ฃผ๊ธฐ
.wrapper { display: flex; flex-wrap: wrap; justify-content: space-between; padding: 0px 20%; text-align: center; } .scale { height: 200px; width: 200px; overflow: hidden; } .scale img { height: 100%; width: 100%; object-fit: cover; transform: scale(1); transition: all 0.5s ease-in-out; } .scale img:hover { cursor: pointer; transform: scale(1.1); transition: all 0.5s ease-in-out; }
[ Result ]
- ์ ์ฒด ๋ ์ด์์
![]()
- ์ด๋ฏธ์ง์ ๋ง์ฐ์ค ํธ๋ฒ ์ : ์ด๋ฏธ์ง ํ๋
flex-wrap: wrap ์์ฑ๋ง์ผ๋ก๋ ์ด๋ฏธ์ง๊ฐ ๋ชจ๋ ๋ถ์ด์๊ฒ ๋๋ฏ๋ก justify-content: space-between์ผ๋ก ๊ฐ๊ฒฉ ์กฐ์ , ๋ํ padding ์ด์ฉํด ์ ์ฒด์ ์ธ ์ด๋ฏธ์ง์ ์์น๋ฅผ ์กฐ์ ํด์ฃผ์๋ค.
์ด๋ฏธ์ง์ ๋ง์ฐ์ค๋ฅผ ํธ๋ฒํ์ ๋ ํ๋ํ๋ ์ ๋๋ฉ์ด์ ์ ๊ตฌํํ์์ผ๋ ์๋ ์ฌ์ง ํฌ๊ธฐ์์ ๋ฒ์ด๋ ๊ธ์จ ๋ถ๋ถ์ ์นจ๋ฒํ๊ฒ ๋์ด ์ด๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด overflow: hidden์ ์ฃผ์ด ํ์ด๋๊ฐ๋ ๋ถ๋ถ์ ๊ฐ๋ ค์ฃผ์๋ค.