로그인 창 만들기 #2 (HTML / CSS 기본)
안녕하세요, 청이입니다.
지난 시간에 만들었던 React 로그인 창이 반응이 엄청 좋았습니다,
- 🔗 React - 로그인창 제작 (HTML / CSS 기본 학습) #1 · blog.naver.com
조금 더 나아가 로그인 입력과 아이콘 액션 등의 기능을 조금 더 추가해보도록 하겠습니다.
- React / CSS 애니메이션
기존 코드를 아래와 같이 수정해 줍니다. (1번 학습 참고)
<LoginPage.js>
import React, {Component} from 'react';
import BackGroundVideo from '../video/main_login.mp4';
import '../css/LoginPage.css'
class LoginPage extends Component {
text;
render() {
return (
<div>
<video autoPlay loop muted
style={{
position: 'absolute',
width: '100vw',
height: '100vh',
objectFit: "cover",
right: "0px",
left: "0px",
top: "0px",
}}>
<source src={BackGroundVideo} type="video/mp4"/>
</video>
<div className="backGroundSet">
<div className="Login_Container">
<div className="Login_Title">
<div className="login_check"></div>
</div>
<div className="Login_from">
<div className="Login_Row">
<svg className="Login_icon" viewBox="0 0 20 20">
<path className="Login_path"
d="M0,20 a10,8 0 0,1 20,0z M10,0 a4,4 0 0,1 0,8 a4,4 0 0,1 0,-8"/>
</svg>
<input type="text" className="login_input_id" placeholder="Username"/>
</div>
<div className="Login_Row">
<svg className="Login_icon" viewBox="0 0 20 20">
<path className="Login_path"
d="M0,20 20,20 20,8 0,8z M10,13 10,16z M4,8 a6,8 0 0,1 12,0"/>
</svg>
<input type="password" className="login_input_pw" placeholder="Password"/>
</div>
<div className="space"></div>
<button type="button" className="login_button">Sign in</button>
<p className="Login_signup">Don't have an account? <a>Sign up</a></p>
</div>
</div>
</div>
</div>
);
}
}
export default LoginPage;
코드의 순서를 유심히 봐야 합니다.

먼저 <div Login_Container> 부분이 아래와 같은 영역을 지정하여 줍니다.

주어진 영역에서, 다시 로고 위치와, 입력값이 제공될 위치 2개로 분할한 것을 확인할 수 있습니다.

<LoginPage.css>
.backGroundSet{
position: absolute;
width: 100%;
height: 100%;
justify-content: center;
align-items: center;
display: flex;
}
.login_check{
position: absolute;
top: 10rem;
left: 13.5rem;
width: 14rem;
height: 2.8rem;
background: #fff;
transform-origin: 0 100%;
transform: rotate(-45deg);
}
.login_check:before{
content: "";
position: absolute;
left: 0;
bottom: 100%;
width: 2.8rem;
height: 5.2rem;
background: #fff;
box-shadow: inset -0.2rem -2rem 2rem rgba(0, 0, 0, 0.2);
}
.Login_Container{
width: 500px;
height: 500px;
background-color: #ffffff;
background-color: rgba( 255, 255, 255, 0);
position: absolute;
justify-content: center;
display: flex;
flex-direction: column;
}
.Login_Title{
position: relative;
width: 100%;
height: 100%;
justify-content: center;
align-items: center;
display: flex;
flex-direction: column;
}
.Login_icon{
padding: 5px;
width: 20px;
height: 20px;
fill: none;
stroke: rgba(255, 255, 255, 0.9);
stroke-width: 1;
overflow: visible;
}
.Login_path{
animation : icon 5s alternate;
}
@keyframes icon {
to {
stroke-dasharray: 80;
}
from {
stroke-dasharray: 0;
}
}
.Login_from{
justify-content: center;
align-items: center;
display: flex;
flex-direction: column;
padding: 1rem 2.5rem 1.5rem;
}
.Login_Row{
padding: 8px;
justify-content: center;
align-items: center;
display: flex;
border-bottom: 1px solid rgba(255, 255, 255, 0.5);
}
.login_input_id{
font-size: 1.0rem;
color: rgba( 255, 255, 255, 0.9);
background: transparent;
border: none;
outline: none;
}
.login_input_pw{
font-size: 1.0rem;
color: rgba( 255, 255, 255, 0.9);
background: transparent;
border: none;
outline: none;
}
.space{
padding: 10px;
}
.login_submit{
position: relative;
width: 30%;
height: 3rem;
color: white;
background-color: rgba( 255, 255, 255, 0.2);
font-size: 1rem;
border-radius: 3rem;
cursor: pointer;
overflow: hidden;
transition: width 0.3s 0.15s, font-size 0.1s 0.15s;
border: none;
outline: none;
display: flex;
justify-content: center;
align-items: center;
}
.login_submit::after{
position : absolute;
content: "";
width: 3rem;
height: 3rem;
border: 2px dotted #fff;
border-radius: 50%;
border-left: none;
border-bottom: none;
transition: opacity 0.1s 0.4s;
opacity: 0;
}
.login_submit.processing {
width: 4rem;
font-size: 0;
}
.login_submit.success {
transition: transform 0.3s 0.1s ease-out, opacity 0.1s 0.3s, background-color 0.1s 0.3s;
transform: scale(30);
opacity: 0.9;
}
.Login_signup{
font-size: 1.2rem;
color: rgba( 255, 255, 255, 0.8);
}
.Login_signup a{
color: #fff;
cursor: pointer;
}
input::placeholder {
color: white;
}
body{
margin: 0;
}
<App.js>
import React, { Component } from 'react'
import LoginPage from './component/LoginPage.js'
import './App.css'
render(){
return(
<div>
<LoginPage/>
</div>
);
}
}
export default App;
위 코드 중, 실행 시 애니메이션이 동작하게 하기 위하여, 아래와 같이 코드를 추가하였는데요,
- 🔗 CSS 애니메이션 사용하기 - CSS: Cascading Style Sheets | MDN · developer.mozilla.org
- 🔗 animation - CSS: Cascading Style Sheets | MDN · developer.mozilla.org
CSS 애니메이션과 관련하여 정리를 잘 한 블로그도 소개합니다.
- 🔗 CSS 애니메이션(Animation), 키프레임(keyframes) · webclub.tistory.com
간단히 본다면
icon : icon ( @keyframes icon 0 ~ 80)
5s : 5초 간
alternate : cw (시계 방향 )에서 ccw (반시계 방향) 즉 애니메이션 동작 방향을 결정합니다.

그 이외에는, 특별히 어렵거나 힘든 코드는 없습니다.
궁금하신 점은 댓글로 남겨 주세요 ~
<결과물>

React를 서서히 조금씩 배워 가고 있는 중입니다.
로그인 프로젝트는 React 실력과 함께 꾸준히 진행할 계획입니다.
#CSS #HTML #JS #학습 #직장인 #개발 #기초 #배경 #동영상 추가 #로그인 화면 #로그인 #display #배치 #순서
댓글
이름만 적고 남길 수 있어요