Interactive online courses HTML Academy
2026-03-09 12:23 Diff

We still need to liven up the decorative selection effect.

In the initial state, there is no selection, so the first thing we need to do is change its width to zero. In order to allow the decorative selection effect to appear when the input field receives the focus, use the CSS rule with these selectors:

input:focus ~ .label-box::before, input:valid ~ .label-box::after { ... }

And in this rule, set the desired width of the border parts.

In order to allow the selection to appear and disappear smoothly, we need to set a smooth transition for both of its parts in this rule:

.label-box::before, .label-box::after { ... }