可以使用 CSS 轻松更改所选文本的颜色 | ::选择选择器。在下面的代码中,我们在和元素上使用了 CSS ::selection并将其颜色设置为黄色和绿色背景。
下面的例子实现了上述方法:
例子:
How to change the color of
selected text using CSS?
GeeksforGeeks
A Computer Science portal for
geeks. It contains well written,
well thought and well explained
computer science and programming
articles, quizzes and many more.
输出: