Introduction to structural pseudo-class selectors
|
property | describe |
---|---|
E:first-letter | Sets the first word in the E element. |
E:first-line | Sets the first line of text in the E element. |
E::before | Add content before the E element. |
E::after | Add content at the end of the E element. |
First-letter practice
Use first-letter
attribute to set the color of the first letter of the text in the li
tag in ul
tag to red.
Code Blocks
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Pseudo-element selector</title> <style> ul li:first-letter{ color: red; } </style> </head> <body> <ul> <li>Smile is the first belief</li> </ul> </body> </html>
Result Plot
First-line practice
Use first-line
attribute to set the color of the first line of text in the div
tag to red.
Code Blocks
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Pseudo-element selector</title> <style> div:first-line{ color: red; } </style> </head> <body> <div> Smile is the first belief, smile is the first belief, smile is the first belief, smile is the first belief, smile is the first belief, Smile is the first belief, smile is the first belief, smile is the first belief, smile is the first belief, smile is the first belief. </div> </body> </html>
Result Plot
beforePractice
Use the before
attribute to add the two words "Come on" before the text of div
tag.
Code Blocks
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Pseudo-element selector</title> <style> div::before{ content:"Come on"; } </style> </head> <body> <div>Smile is the first belief. </div> </body> </html>
Result Plot
Note: The added text must be written inside content:"加油";
.
after practice
Use after
attribute to add the two words "Come on" at the end of the text of div
tag.
Code Blocks
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Pseudo-element selector</title> <style> div::after{ content:"Come on"; } </style> </head> <body> <div>Smile is the first belief,</div> </body> </html>
Result Plot
Note: The added text must be written inside content:"加油";
.
The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.
<<: Tips for List Building for Website Maintenance Pages
>>: Analysis of the difference between bold <b> and <strong>
Overview This article is a script for automatical...
Table of contents Preface Problem Description Cau...
Table of contents The order in which MySQL reads ...
Nginx is a powerful, high-performance web and rev...
Table of contents text 1. Prepare the machine 2. ...
Directly code: select 'bigint unsigned' a...
operating system: Win10 Home Edition Install Dock...
1. Prepare the Java environment, jdk1.8 Check whe...
Overview binlog2sql is an open source MySQL Binlo...
I have encountered the problem that MySQL can con...
This article example shares the specific code of ...
Install PostgreSQL 11 on CentOS 7 PostgreSQL: The...
For more exciting content, please visit https://g...
I have been taking a lot of MySQL notes recently,...
When using Navicat to connect to a remote Linux M...