๐ ๋ก๊ทธ์ธ ํ์ด์ง์์ ์์ด๋๋ ๋น๋ฐ๋ฒํธ๋ฅผ ๋ชจ๋ ์ ๋ ฅํ ๊ฒฝ์ฐ์ ๋ก๊ทธ์ธ ๋ฒํผ ํ์ฑํ ์ํค๊ธฐ
๐ ๋ด๊ฐ ๊ตฌํํ westagram
๐ westagram clone์ฝ๋ฉ javascript login page code
โ๏ธ ๋ด๊ฐ ์์ฑํ html ์ฝ๋
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=3.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>westagram</title>
<!-- ์ธ๋ถ ์คํ์ผ์ํธ ์ฐ๊ฒฐ -->
<link rel="icon" type="image/png" href="imgs/favicon.png" />
<link rel="stylesheet" href="common.css">
<link rel="stylesheet" href="login.css">
<style type="text/css"></style>
<!-- ์ธ๋ถ ์คํฌ๋ฆฝํธ ์ฐ๊ฒฐ -->
<script src="login.js" defer></script>
<!-- ํฐํธ์ด์ธ -->
<script src="https://kit.fontawesome.com/684e97b7f2.js" crossorigin="anonymous"></script>
</head>
<!-- body start -->
<body>
<!-- ๊ฐ์ธ์ง ํฐ section -->
<section class="container-wrap">
<!-- westagram ๊ธ์ -->
<h2 class="login-title">WESTAGRAM</h2>
<!-- input,button๊ฐ์ธ๊ณ ์๋ form -->
<form class="input-container">
<!-- input์ ๊ฐ์ธ๊ณ ์๋ div -->
<div class="input-wrap">
<input id="id" type="text" placeholder="์ ํ๋ฒํธ,์ฌ์ฉ์์ด๋ฆ ๋๋ ์ด๋ฉ์ผ">
<input id="password" type="password" placeholder="๋น๋ฐ๋ฒํธ">
</div>
<!-- ๋ก๊ทธ์ธ ๋ฒํผ -->
<button class="btn" type="submit" disabled>
๋ก๊ทธ์ธ
</button>
</form>
<!-- ๋ง์ง๋ง ๋น๋ฐ๋ฒํธ๋ฅผ ์์ผ์
จ๋์ div -->
<div class="last">
<p><a href="#">๋น๋ฐ๋ฒํธ๋ฅผ ์์ผ์
จ๋์?</a></p>
</div>
</section>
</body>
</html>
โ๏ธ ๋ด๊ฐ ์์ฑํ Common.css ์ฝ๋ ๐ css๊ณตํต ํ์ผ
@import url("https://fonts.googleapis.com/css2?family=Lobster&display=swap");
* {
margin: 0;
padding: 0;
box-sizing: border-box;
border: px solid silver;
}
img {
width: 50px;
}
body {
font-family: "Roboto", sans-serif;
font-size: 0.9rem;
line-height: 1rem;
color: #999;
letter-spacing: 0.1px;
}
h1,
h3 {
font-family: "Oswald", sans-serif;
}
h1 {
font-size: 4rem;
line-height: 4rem;
text-transform: uppercase;
}
h2 {
font-size: 2.4rem;
line-height: 2.4rem;
text-transform: uppercase;
}
h3 {
font-size: 1.4rem;
line-height: 1.4rem;
}
h4,
h5 {
font-family: "Playfair Display", serif;
}
h4 {
font-size: 1.1rem;
line-height: 1.1rem;
}
h5 {
font-size: 0.7rem;
line-height: 0.7rem;
}
p {
color: black;
}
a:link {
color: #666;
text-decoration: none;
}
a:visited {
color: #666;
}
a:hover {
color: red;
}
a:active {
color: red;
}
button {
font-size: 0.7rem;
text-transform: uppercase;
padding: 10px 30px;
border: 1px solid #ccc;
background: white;
transition: 0.3s;
}
button:hover {
background: crimson;
color: white;
cursor: pointer;
}
โ๏ธ ๋ด๊ฐ ์์ฑํ login.css ์ฝ๋
@import url('https://fonts.googleapis.com/css2?family=Lobster&display=swap');
h2 {
font-family: 'Lobster', cursive;
}
.container-wrap {
width: 700px;
margin: 3rem auto;
border: 1px solid rgb(206, 206, 206);
}
.login-title {
color: #24292f;;
font-size: 3.5rem;
font-weight: 400;
text-align: center;
line-height: 4rem;
letter-spacing: -1px;
margin-top: 3rem;
}
/* input */
.container-wrap > :nth-child(2) {
width: 500px;
margin: 4rem auto;
}
input, textarea {
width: 500px;
font-size: 18px;
margin-bottom: 10px;
border-radius: 4px;
padding: 20px 12px;
border: 1px solid silver;
background-color: rgba(240, 239, 239, 0.562);
color: rgba(196, 196, 196, 0.562);
}
input:focus {
outline: 1px solid rgb(130, 167, 235);
}
.btn {
width: 500px;
border-radius: 8px;
padding: 16px 12px;
margin: 1.4rem auto;
font-size: 22px;
color: white;
font-weight: bolder;
background-color: #0098f63d;
border: none;
}
.btn:hover {
background-color: #0096F6;
}
.last {
font-size: 20px;
text-align: center;
margin-bottom: 3rem;
margin-top: 12rem;
}
.last p a {
color: #0e527cfd;
font-weight: bolder;
}
โ๏ธ ๋ด๊ฐ ์์ฑํ login.js ์ฝ๋
"use strict";
const inputId = document.querySelector('#id');
const inputPassword = document.querySelector('#password');
const button = document.querySelector('.btn');
function loginBtn(){
let idValu = inputId.value;
let passwordValue = inputPassword.value;
if(idValu.length > 0 && passwordValue.length > 0) {
button.disabled = false;
button.style.cursor = 'pointer';
button.style.backgroundColor = '#1c7ed6';
}else {
button.disabled = true;
button.style.cursor = 'default';
button.style.backgroundColor = '#bfdffd';
}
};
inputId.addEventListener('keyup', loginBtn);
inputPassword.addEventListener('keyup', loginBtn);
โ
์๋ฐ์คํฌ๋ฆฝํธ๋ก ๋ก๊ทธ์ธ ํ์ด์ง๋ฅผ ์ฝ๋ฉํ๊ณ ๋์์ ํ๊ณ
๐ ๋จ์ํ๊ฒ css์์ฑ์ผ๋ก ๋ง์ฐ์ค๋ฅผ ๊ฐ์ ธ๋ค๋์์๋ ํธ๋ฒ๋ก ๋ก๊ทธ์ธ ๋ฒํผ ์์์ ๋ณํ๊ฒ ํ๋ ๊ฒ์ด ์๋๋ผ javascript์์ ์กฐ๊ฑด์ ๋ง์กฑํ ๊ฒฝ์ฐ์ disabled์์ฑ์ ๋นํ์ฑํ ์์ผ์ ๋ฒํผ์ ์์ ํ์ฑํ ์ํค๋ ๋ก์ง์ ๊ตฌํํด๋ณด์๋ค.