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!
Statement of this 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
How to achieve wave effect with pure CSS3? This article will introduce to you how to use SVG and CSS animation to create wave effects. I hope it will be helpful to you!
Two methods: 1. Using the display attribute, just add the "display:none;" style to the element. 2. Use the position and top attributes to set the absolute positioning of the element to hide the element. Just add the "position:absolute;top:-9999px;" style to the element.
In CSS, you can use the border-image attribute to achieve a lace border. The border-image attribute can use images to create borders, that is, add a background image to the border. You only need to specify the background image as a lace style; the syntax "border-image: url (image path) offsets the image border width inward. Whether outset is repeated;".
How to create text carousel and image carousel? The first thing everyone thinks of is whether to use js. In fact, text carousel and image carousel can also be realized using pure CSS. Let’s take a look at the implementation method. I hope it will be helpful to everyone!
Adaptive layout, also known as "responsive layout", refers to a web page layout that can automatically recognize the screen width and make corresponding adjustments; such a web page can be compatible with multiple different terminals instead of making a specific version for each terminal. . Adaptive layout was born to solve the problem of mobile web browsing, and can provide a good user experience for users using different terminals.
Reasons for pseudo-element failure: 1. Selector issues; 2. Style conflicts; 3. Inheritance issues; 4. Syntax errors; 5. Browser compatibility issues, etc. Detailed introduction: 1. Selector problem, the selector of the pseudo element may be incorrect, resulting in the target element not being selected; 2. Style conflict, if there is a style conflict in CSS, the pseudo element may become invalid; 3. Inheritance problem, Pseudo elements may not inherit certain style attributes; 4. Syntax errors. If there are syntax errors in CSS, the pseudo elements may fail; 5. Browser compatibility issues, etc.
In the previous article "Css Pseudo-Selector Learning - Pseudo-Element Selector Analysis", we learned about pseudo-element selectors, and today we take a closer look at pseudo-class selectors. I hope it will be helpful to everyone!