12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- <style>
- p{
- font-size: 30px;
- }
- /*
- 伪元素:表示页面中一些特殊的并不真实存在的元素(特殊的位置)
- 伪元素使用“::”开头
- ::first-letter 表示第一个字母
- ::first-line 表示第一行
- ::selection 表示选中的内容
- ::before 表示元素的开始位置(第一个字与标签符号之间的位置)
- ::after 表示元素的最后的位置(最后一个字与标签符号之间的位置)
- -before和after必须结合content属性来使用
- -通过before和after添加的内容,在进行选中操作时不会被选中
- */
- p::first-letter{
- font-size: 50px;
- }
- p::first-line{
- background-color: yellow;
- }
- p::selection{
- background-color: yellowgreen;
- }
- div::before{
- content: 'abc';
- color: red;
- }
- div::after{
- content: 'nice';
- color: red;
- }
- </style>
- </head>
- <body>
- <div>Hello Hello World</div>
- <p>
- Lorem ipsum dolor sit amet consectetur adipisicing elit. Ea consequatur numquam voluptatibus excepturi recusandae molestiae accusamus placeat libero aliquid quis? Rerum ab ut sunt enim minus, nam consectetur exercitationem aliquid.
- </p>
- </body>
- </html>
|