- index.html
- style.css
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<title>Checkboxes, step 3</title>
<meta charset="utf-8">
<link rel="stylesheet" href="material.css">
<link rel="stylesheet" href="style.css">
</head>
<body class="green-theme">
<section class="card">
<h1 class="question"><span>What are the correct values for the position property?</span></h1>
<form class="answers" action="https://echo.htmlacademy.ru/courses" method="post">
<button class="fab" type="submit"></button>
<div>
<input type="checkbox" id="answer1">
<label for="answer1">absolute</label>
</div>
<div>
<input type="checkbox" id="answer2">
<label for="answer2">great</label>
</div>
<div>
<input type="checkbox" id="answer3">
<label for="answer3">majestic</label>
</div>
</form>
</section>
</body>
</html>
CSS
label {
position: relative;
cursor: pointer;
}
label::before {
position: absolute;
top: 0;
left: -44px;
z-index: 1;
width: 16px;
height: 16px;
border: 2px solid #5a5a5a;
content: "";
}
input[type="checkbox"] {
display: none;
}
input[type="checkbox"]:checked ~ label::before {
width: 21px;
height: 10px;
border-color: #00bad2;
border-top-style: none;
border-right-style: none;
}
You’ve gone to a different page
Goalscompleted
0
- Set a
transform: rotate(-45deg)
rotation for the selected state of the “pseudo-checkbox”. - And then assign a smooth transition for both properties with a duration of
0.3s
and the formease-in-out
forlabel::before
.
Toggle the checkboxes to test the result.
- Select the correct answer to the quiz question, and press the round button to check your answer.
Comments