Background-color from Lection does not work

Asked

Viewed 473 times

0

I have the following CSS:

*::selection {background-color:red;color:blue;}
*::-moz-selection {background-color:red;color:blue;}
*::-webkit-selection {background-color:red;color:blue;}

Where, any part of the text, it leaves the background in red and the text in blue.

Only that the background-color is not working.

  • 3

    will see the browser thought that blue on top of red would look very ugly :P

1 answer

1


Maybe some other rule is overriding this one because the CSS is correct and working.

selection

Try declaring this rule right at the beginning of the CSS file, above any other definition.

::selection {background-color:red;color:blue;}
::-moz-selection {background-color:red;color:blue;}
::-webkit-selection {background-color:red;color:blue;}

/* outras regras... */
<p>Quisque sollicitudin elit sed orci gravida, nec accumsan enim pulvinar.
Curabitur eu turpis non nulla sodales consequat in in turpis. Ut iaculis, elit
dapibus interdum vulputate, mi nibh finibus neque, scelerisque commodo massa
odio ut diam. Cras nec massa eget tellus mattis consequat. Nulla ut dictum enim.
Proin molestie gravida sapien, at tincidunt erat ultrices vel. Integer in quam
in arcu rutrum malesuada at.</p>

  • 1

    That’s exactly what happened. The CSS of a plugin I’m using was applying a *::selection {background-color:transparent;color:blue;}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.