伪元素选择器
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>伪元素选择器</title>
<style>
p{
font-size: 20px;
}
/*
伪元素, 表示页面中一些特殊并不真实存在的元素(特殊的位置)
伪元素使用 :: 开头
::first-letter 表示第一个字母
::first-line 表示第一行
::selection 表示选中的内容
::before 表示元素的开始
::after 表示元素的最后
-before和after必须结合content属性来使用
-content 设置的文本内容
*/
p::first-letter{
font-size: 30px;
}
p::first-line{
background-color: yellow;
}
p::selection{
background-color:green;
}
div::before{
content: 'before';
color: hotpink;
}
div::after{
content: 'after';
color: skyblue;
}
</style>
</head>
<body>
<div>Hello Hello How are you</div>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Unde culpa, facilis nulla architecto magnam doloribus ipsum? Sint, rerum impedit quod nesciunt vitae at aliquid earum sequi excepturi. Nihil, aliquid expedita?</p>
</body>
</html>
It's never too late to be the person you want to be.
去做你想成为的那个人永远都不会晚

浙公网安备 33010602011771号