HTML _CSS
Checkbox Custom
HiroDaegu
2022. 8. 30. 00:15
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>CUSTOM CHECKBOX</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<label>
<input type="checkbox">
<span></span>
<text>OFF</text>
<text>ON</text>
</label>
</body>
</html>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: linear-gradient(#555, #292929);
}
label {
position: relative;
width: 300px;
height: 150px;
background-color: #3E3E3E;
box-shadow: 0 0 0 4px #303030;
border-radius: 75px;
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;
}
label input {
appearance: none;
}
label span {
position: absolute;
left: 0;
width: 175px;
height: 150px;
background: url(Coffee_01.png);
background-size: auto 150px;
background-repeat: no-repeat;
transition: 1.5s;
transform: rotate(-180deg);
transform-origin: 75px;
}
label input:checked ~ span {
left: 150px;
background: url(Coffee_02.png);
background-size: auto 150px;
background-repeat: no-repeat;
transform: rotate(360deg);
}
label text {
position: absolute;
left: -100px;
font-family: consolas;
color: #FFF;
font-size: 3em;
filter: drop-shadow(0 0 15px #FFF) drop-shadow(0 0 35px #FFF);
transition: 1.5s;
}
label input:checked ~ text {
color: #8F8F8F;
filter: none;
}
label text:last-child {
position: absolute;
left: initial;
right: -100px;
color: #FFF;
filter: none;
}
label input:checked ~ text:last-child {
color: #FFF;
filter: drop-shadow(0 0 15px #FFF) drop-shadow(0 0 35px #FFF);
}
728x90
LIST