fix: Improve ::selection example and description
This commit is contained in:
@ -11,6 +11,10 @@ Changes the styling of text selection.
|
||||
#### CSS
|
||||
|
||||
```css
|
||||
::selection {
|
||||
background: aquamarine;
|
||||
color: black;
|
||||
}
|
||||
.custom-text-selection::selection {
|
||||
background: red;
|
||||
color: white;
|
||||
@ -20,10 +24,19 @@ Changes the styling of text selection.
|
||||
#### Demo
|
||||
|
||||
<div class="snippet-demo">
|
||||
<p class="snippet-demo__custom-text-selection">Select some of this text.</p>
|
||||
<p>Global aquamarine selection color</p>
|
||||
<p class="snippet-demo__custom-text-selection">Red selection color.</p>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
::selection {
|
||||
background: aquamarine;
|
||||
color: black;
|
||||
}
|
||||
::-moz-selection {
|
||||
background: aquamarine;
|
||||
color: black;
|
||||
}
|
||||
.snippet-demo__custom-text-selection::selection {
|
||||
background: red;
|
||||
color: white;
|
||||
@ -36,7 +49,7 @@ Changes the styling of text selection.
|
||||
|
||||
#### Explanation
|
||||
|
||||
`::selection` defines a pseudo selector on an element to style text within it when selected.
|
||||
`::selection` and `::-moz-selection` defines a pseudo selector on an element to style text within it when selected. Note that if you don't combine any other selector your style will be applied at document root level, to any selectable element.
|
||||
|
||||
#### Browser support
|
||||
|
||||
|
||||
Reference in New Issue
Block a user