Problem: Custom Radio Button Control
Problem description
Given an HTML page containing a label with the class .custom-radio that wraps a native radio input named option, a span element with the class .radio-mark, and the text “Option A’’ (and similarly for “Option B’’), write CSS to:
Hide the native
input[type="radio"].Style the
.radio-markas a20px × 20pxcircle with a2px solidborderand50%border-radius.Change the
border-colorof the.radio-markto#4CAF50when the radio is:checked.Use
::afteron.radio-markto draw a10px × 10pxfilled circular dot at the center when:checked.
Goal
Write CSS rules to render two custom radio controls labeled “Option A” and “Option B”, where only the selected option shows a green border and inner dot.
Constraints
Use only CSS (no JavaScript is allowed).
.radio-marksize should be20pxby20px.Bordershould be2px solid #666,border-radiusshould be50%.Checked
border-colorshould be#4CAF50.Inner dot should be
10pxdiameter, centered,background-colorshould be#4CAF50, drawn via::after.
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: Custom Radio Button Control
Problem description
Given an HTML page containing a label with the class .custom-radio that wraps a native radio input named option, a span element with the class .radio-mark, and the text “Option A’’ (and similarly for “Option B’’), write CSS to:
Hide the native
input[type="radio"].Style the
.radio-markas a20px × 20pxcircle with a2px solidborderand50%border-radius.Change the
border-colorof the.radio-markto#4CAF50when the radio is:checked.Use
::afteron.radio-markto draw a10px × 10pxfilled circular dot at the center when:checked.
Goal
Write CSS rules to render two custom radio controls labeled “Option A” and “Option B”, where only the selected option shows a green border and inner dot.
Constraints
Use only CSS (no JavaScript is allowed).
.radio-marksize should be20pxby20px.Bordershould be2px solid #666,border-radiusshould be50%.Checked
border-colorshould be#4CAF50.Inner dot should be
10pxdiameter, centered,background-colorshould be#4CAF50, drawn via::after.
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.