+
95
-

回答

可以设置::selection,示例代码如下:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
body {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
width: 50%;
margin: auto;
font-family: "Baloo 2", cursive;
font-size: 1.5rem;
}
::selection {
background-color: #3bd174;
color: white;

}
</style>
</head>
<body>
<p>
The ::selection CSS pseudo-element applies styles to the part of a
document that has been highlighted by the user (such as clicking and
dragging the mouse across text).
</p>
</body>
</html>


网友回复

我知道答案,我要回答