Pricing pages often let visitors flip every plan between a monthly and a yearly price with a single switch. It is a small component, but it touches a lot of CSS: restyling a native form control, reacting to its state without JavaScript, and a card layout that has to hold up on a phone and on a wide screen.
You are given the markup for a pricing section with three plans and a billing switch. Write only CSS in styles.css (no JavaScript, and no changes to the HTML) so that the page meets these requirements.
The switch
<input type="checkbox" role="switch">. Do not hide it with display: none or visibility: hidden, since it must stay focusable and keep its accessible name from the "Yearly" label.appearance: none) and draw it as a pill-shaped track that is wider than it is tall, with a round thumb drawn by a pseudo-element.:focus-visible).prefers-reduced-motion: reduce).The prices
.price-monthly and a .price-yearly price. Only one may be shown at a time: monthly while the switch is unchecked, yearly while it is checked.:has().The layout
.plan-featured) is taller than the other two, which are centered vertically next to it. Give it a different background or border so it stands out.Wide screen, yearly selected
Monthly ( ●) Yearly (2 months free)
┌───────────────┐
┌──────────┐ │ Team │ ┌──────────┐
│ Hobby │ │ $240/year │ │ Business │
│ $80/year │ │ 10 projects │ │ $590/year│
│ 1 project│ │ ... │ │ ... │
│ │ │ │ │ │
│ [Choose] │ │ │ │ [Choose] │
└──────────┘ │ [Choose Team] │ └──────────┘
└───────────────┘
Credit: the idea comes from the Frontend Mentor challenge Pricing component with toggle. This version uses its own markup and requirements.
Wide screen, yearly selected
Monthly ( ●) Yearly (2 months free)
┌───────────────┐
┌──────────┐ │ Team │ ┌──────────┐
│ Hobby │ │ $240/year │ │ Business │
│ $80/year │ │ 10 projects │ │ $590/year│
│ 1 project│ │ ... │ │ ... │
│ │ │ │ │ │
│ [Choose] │ │ │ │ [Choose] │
└──────────┘ │ [Choose Team] │ └──────────┘
└───────────────┘