css3 pseudo-elements include: 1. "::after", which can insert some content after the specified element; 2. "::before"; 3. "::first-letter"; 4. " ::first-line"; 5. "::selection"; 6. "::placeholder".
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
Pseudo-element is a keyword appended to the end of the selector. Through pseudo-element, you can define styles for specific parts of the selected element without using the element's ID or class attributes. For example, through pseudo-elements you can set the style of the first letter in a paragraph, or insert some content before or after the element, etc.
In CSS1 and CSS2, the use of pseudo-elements is the same as pseudo-classes, and a colon : is connected to the selector. However, in CSS3, the use of single colon for pseudo elements was changed to double colon :: to distinguish pseudo classes and pseudo elements. Therefore, it is recommended to use double colons instead of single colons when using pseudo-elements.
selector::pseudo-element {
property: value;
}
Copy after login
Among them, selector is the selector, pseudo-element is the name of the pseudo element, property is the property in CSS, value is the value corresponding to the attribute.
CSS provides a series of pseudo-elements, as shown in the following table:
Pseudo-elements
Example
Example description
::after
p::after
Insert content after each
element
::before
p::before
Insert content before each
element
: :first-letter
p::first-letter
Matches the first letter of the content in each
element
##::first -line
p::first-line
Matches the first line of content in each
element
::selection
p::selection
Match the part of the element selected by the user
::placeholder
input::placeholder
Match the placeholder attribute of each form input box (such as )
The above is the detailed content of What are the css3 pseudo elements?. For more information, please follow other related articles on the PHP Chinese website!
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn