:: The selection pseudo class selector is used for highlighting any part of the page user selection, including text in editable text fields.
This pseudo element can be applied to color, background-color, background (Background-color) and Text-shadow (Note: This property is not valid under IE at the current location) property. Setting other properties has no effect.
Firefox needs to add the-moz-attribute prefix;
Support browsers: Chrome,firefox (Gecko), Internet Explorer 9+,opera,safari
For example:
| The code is as follows |
Copy Code |
/* Draw any selected text yellow on red background * * ::-moz-selection {color:gold; background:red; } :: Selection {color:gold; background:red; }
/* Draw selected text in a paragraph p::-moz-selection {color:white; Background:black; } p::selection {color:white; Background:black; } |
A complete example:
| The code is as follows |
Copy Code |
<! DOCTYPE html> <meta charset= "Utf-8"/> <TITLE>CSS:: Selection pseudo class selector-web front-end development </title> <meta name= "Author" content= "The Pier of Fools, www.css88.com"/> <style> p{text-shadow:2px 2px 5px #333333;} P::-moz-selection{background: #000; color: #f00; text-shadow:2px 2px 5px #FFFF2E;} P::selection{background: #000; color: #f00; text-shadow:2px 2px 5px #FFFF2E;} </style> <body> <p> After you select this text, look at their text color and background colors, you can understand:: The role of selection. </p> </body>
|
The effect is as follows