CSS implementation of modifying the color and background color of the selected text on the web page

web front end thirteen thousand and eighty-eight 12 years ago (2012-05-16)

First of all, thank you for visiting Tuoyuan Network , if you are using IE9 Firefox, Chrome, Safari, Opera, etc browser Try to select the text on any page of Tuoyuan. You will find that the color of the selected text and the background color are quite different from those of other websites because of the following CSS:

 ::selection {color: #fff; background-color: #cc3333;}     ::-moz-selection {color: #fff; background-color: #cc3333;}

After the above code is added to the style sheet, the selected text on the web page will be white, and the background color of the selected text will be dark gray. IE8 and below browsers are not supported.

I personally do not recommend it for commercial websites, but for personal blog websites or design websites. If you have a better method, you can put it forward for everyone to exchange and learn, so that they can make common progress!