HTML _CSS
Input Label Animation
HiroDaegu
2022. 11. 28. 11:28
728x90
SMALL


<!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>INPUT LABEL ANIMATION</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div class="inputBox">
<input type="text" required>
<span>Full Name</span>
<i></i>
</div>
</div>
</body>
</html>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
position: relative;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: linear-gradient(45deg, #2196F3, #FF4685);
}
.container {
padding: 50px;
background-color: #FFF;
display: flex;
justify-content: center;
align-items: center;
border-radius: 8px;
box-shadow: 0 15px 35px rgba(0, 0, 0, .25);
}
.container .inputBox {
width: 350px;
}
.container .inputBox input {
padding: 8px 10px;
border: none;
outline: none;
background-color: transparent;
color: #FFF;
font-size: 1.25em;
letter-spacing: .05em;
z-index: 2;
}
.container .inputBox span {
position: absolute;
left: 0;
padding: 10px 0;
pointer-events: none;
font-size: 1em;
transition: .5s;
color: #333;
letter-spacing: .05em;
}
.container .inputBox input:valid ~ span,
.container .inputBox input:focus ~ span {
font-size: .85em;
transform: translateY(-32px);
}
.container .inputBox i {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 3px;
background: linear-gradient(45deg, #2196F3, #FF4685);
transition: .5s;
z-index: 1;
border-radius: 4px;
pointer-events: none;
}
.container .inputBox input:valid ~ i,
.container .inputBox input:focus ~ i {
height: 100%;
box-shadow: inset 0 0 10px rgba(0, 0, 0, .25);
}728x90
LIST