Lesson 19 of 50
cssPseudo‑Classes & Pseudo‑Elements
12 mins
Course progress38%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 19 of 50
css12 mins
Keep these ideas in mind as you work through the lesson.
Pseudo‑classes (:hover, :focus, :nth-child, :not, :has) target states or structure of an element.
Pseudo‑elements (::before, ::after, ::first-line, ::first-letter) create virtual child elements.
::after.btn {
position:relative; padding:0.8rem 1.5rem; overflow:hidden;
}
.btn::after {
content:""; position:absolute; inset:0; background:linear-gradient(45deg,var(--c1),var(--c2));
transform:scaleX(0); transform-origin:left; transition:transform .3s;
}
.btn:hover::after { transform:scaleX(1); }