Page 1 of 1

Highlight color after selection

Posted: 08 Nov 2017, 09:51
by GeoPal
Hi Karl,
Wanted to ask you if there is any setting for the colour of text highlight after selection with mouse? I couldn't find it and now it maybe is the default for the browser.
Is there a way to change the colour with css?
Thank you, George

Re: Highlight color after selection

Posted: 08 Nov 2017, 09:56
by mjau-mjau
Check this link:
https://css-tricks.com/almanac/selectors/s/selection/

You will have to add custom CSS naturally.

Re: Highlight color after selection

Posted: 10 Nov 2017, 04:25
by GeoPal
Thank you Karl, worked like a charm!
Best, George

Re: Highlight color after selection

Posted: 10 Nov 2017, 10:18
by GeoPal
p.s.
In the text body it works, but it doesn't in the Title and description. Any idea? 

Link
This is the code I put in custom css:

Code
p::selection {
  background-color: #000;
  color: white;
}
Thank you! 
G

Re: Highlight color after selection

Posted: 10 Nov 2017, 10:38
by mjau-mjau
Because the p:: means it will target all <p> paragraph items only, and your "content" is generally made up from paragraphs.

You could add the selection class GLOBALLY like this:
Code
::selection {
  background-color: #000;
  color: white;
}
It might not be a good idea to add the selection style to EVERYTHING though (menu's etc). To also target headers (including title and description), you might want to try this instead:
Code
p::selection, h1::selection, h2::selection {
  background-color: #000;
  color: white;
}