::selection选择器匹配元素中被用户选中或处于高亮状态的部分。
::selection只可以应用于少数的CSS属性:color, background, cursor,和outline。
效果
![](https://img.haomeiwen.com/i13122745/fa6329394c7e9473.png)
代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
::selection {
background: red;
}
::-moz-selection {
background: red;
}
::-webkit-selection {
background: red;
}
.box-shadow {}
</style>
<body>
<div class="box-shadow">asfsadasdasdasd</div>
</body>
</html>
网友评论