课程: CSS Essential Training

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Pseudo-classes and pseudo-elements

Pseudo-classes and pseudo-elements - CSS教程

课程: CSS Essential Training

Pseudo-classes and pseudo-elements

- [Instructor] So far, we've gone over different ways to select specific elements, but with pseudo-class and pseudo-element selectors we can select a specific state or a specific part of an element. Pseudo-classes target elements in a specific state. For example, the first child element or when the user interacts with it such as hovering over a link. They're added to a selector with a colon and a keyword. Pseudo-elements are used to style a specific part of an element, such as the first letter or the first line of a paragraph. They're also combined with a selector but are added with double colons followed by the keyword. Let's look at an example in CodePen. A common style for online articles is to mimic the typography often seen in magazines by styling the first paragraph or first sentence differently from the rest. Let's start by adding the first class to the first paragraph. Inside the opening tag I'll add the…

内容