Use CSS3 :: selection pseudo-element to change the selected background color

When Windows selects the default text, the background is blue and the foreground color is white.

Firefox, Safari, Chrome and Opera browsers all support the text selection attribute. If the browser does not support this attribute, it will be ignored directly. So there will be no adverse effects

 <style>
     ::selection{
           background:blue;
           color:#ccc;
     }
 </style>

A piece of simple code is easy to get ~

Published 248 original articles · Like 602 · Visit 1.08 million +

Guess you like

Origin blog.csdn.net/qq_32963841/article/details/104122497