Problem: Three-State Checkbox with Indeterminate Animation
Problem description
Given an HTML page containing the following:
A
<label>with classtri-checkboxthat wraps:A native
<input type="checkbox" class="tri-state">A
<span class="checkmark"></span>The text “Agree to terms”
Write CSS to:
Hide the native checkbox input.
Style
.checkmarkas a20px × 20pxsquare with a2px solid #666 borderand4px border-radius.Checked state (
input:checked + .checkmark):Use a blue background (
#2196F3) and matchingborder.Display a white tick mark using the
::afterpseudo-element (6px × 10px), positioned inside the box.
Indeterminate state (
input:indeterminate + .checkmark):Use a gray horizontal dash (
::before) centered in the box (12px × 2px).Animate the dash with a pulsing scale effect using
@keyframes pulse.
Ensure smooth transitions for background,
border, and pseudo-elements.
Goal
Write CSS rules that produce a custom tri-state checkbox with these visual states:
Unchecked: A gray-bordered box
Checked: A white checkmark on a blue background
Indeterminate: A gray dash that pulses in place
Constraints
Use CSS only (no JavaScript is allowed).
.checkmarksize should be20pxby20px;bordershould be2px solid #666;border-radiusshould be4px.Checked
background-colorshould be#2196F3.Checked tick should be white, drawn via
::after, with border-based tick shape.Indeterminate dash should be white,
12pxwide,2pxtall, centered viaabsolutepositioning.Animation should be
pulsekeyframes scaling dash from0.8×to1.2×over1sinfinite ease-in-out.State selectors should be
input:checkedandinput:indeterminate.
Sample visual output
Here’s what the output would look like:
Good luck trying the problem! If you’re unsure how to proceed, check the Solution.
Problem: Three-State Checkbox with Indeterminate Animation
Problem description
Given an HTML page containing the following:
A
<label>with classtri-checkboxthat wraps:A native
<input type="checkbox" class="tri-state">A
<span class="checkmark"></span>The text “Agree to terms”
Write CSS to:
Hide the native checkbox input.
Style
.checkmarkas a20px × 20pxsquare with a2px solid #666 borderand4px border-radius.Checked state (
input:checked + .checkmark):Use a blue background (
#2196F3) and matchingborder.Display a white tick mark using the
::afterpseudo-element (6px × 10px), positioned inside the box.
Indeterminate state (
input:indeterminate + .checkmark):Use a gray horizontal dash (
::before) centered in the box (12px × 2px).Animate the dash with a pulsing scale effect using
@keyframes pulse.
Ensure smooth transitions for background,
border, and pseudo-elements.
Goal
Write CSS rules that produce a custom tri-state checkbox with these visual states:
Unchecked: A gray-bordered box
Checked: A white checkmark on a blue background
Indeterminate: A gray dash that pulses in place
Constraints
Use CSS only (no JavaScript is allowed).
.checkmarksize should be20pxby20px;bordershould be2px solid #666;border-radiusshould be4px.Checked
background-colorshould be#2196F3.Checked tick should be white, drawn via
::after, with border-based tick shape.Indeterminate dash should be white,
12pxwide,2pxtall, centered viaabsolutepositioning.Animation should be
pulsekeyframes scaling dash from0.8×to1.2×over1sinfinite ease-in-out.State selectors should be
input:checkedandinput:indeterminate.
Sample visual output
Here’s what the output would look like:
Good luck trying the problem! If you’re unsure how to proceed, check the Solution.