<html lang="en">
<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>Document</title>
</head>
<body>
<form>
<fieldset>
<legend>좋아하는 음식을 고르세요:</legend>
<div class="checkboxWrapper">
<input
type="checkbox"
id="songpyeon"
name="food"
value="songpyeon"
checked
/>
<label for="songpyeon"> 송편 </label>
</div>
<div class="checkboxWrapper">
<input
type="checkbox"
id="friedShrimp"
name="food"
value="friedShrimp"
/>
<label for="friedShrimp">새우튀김</label>
</div>
</fieldset>
</form>
</body>
</html>
.checkboxWrapper {
position: relative;
}
.checkboxWrapper label {
display: block;
padding: 2px 0 2px 24px;
}
.checkboxWrapper input {
height: 20px;
width: 20px;
position: absolute;
top: 0;
left: 0;
opacity: 0;
}
.checkboxWrapper input + label::before {
content: '';
height: 20px;
width: 20px;
background-color: #d9d9d9;
border-radius: 1px;
position: absolute;
top: 0;
left: 0;
}
.checkboxWrapper input + label::after {
content: '';
border: 2px solid #ffffff;
border-left: 0;
border-top: 0;
height: 10px;
width: 6px;
transform: rotate(45deg);
position: absolute;
top: 1px;
left: 6px;
opacity: 0;
transition: opacity 0.2s ease-in-out;
}
.checkboxWrapper input:checked + label::before {
background-color: #2ac1bc;
transition: 0.2s ease-in-out;
}
.checkboxWrapper input:checked + label::after {
opacity: 1;
}
.checkboxWrapper input:focus + label::before {
box-shadow: 0 0 0 3px #2ac1bc;
outline: 3px solid transparent;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.