1

We have a link that is often copied to the users email tool, including color and background color. Since there is a Whitelabel solution, this can cause a problem when the text is white.

  1. text is white
  2. user selects the text to copy it
  3. text is white again (and in the worst case, the background color is lost)

I know the ::selection pseudo class, but it doesn't help for the copy process. See this fiddle: https://jsfiddle.net/vvfL2516/

.background { background: #222; }

.link { color: #fff; }
.link::-moz-selection {
    background: #f00;
    color: #0f0;
}
.link::selection {
    background: #f00;
    color: #0f0;
}

Thunderbird shows a blue link (=nice), but it's invisible in Libre Office and Google Docs, ... (not nice)

Update 2015-09-24:

The link form Andrew Lyndem contains the answer: https://stackoverflow.com/a/7454048/461754

Community
  • 1
  • 1
netzaffin
  • 1,602
  • 3
  • 13
  • 14

1 Answers1

0

if you really really want to change it, use not only active and focus a attributes, but also an a:hover so that it highlights when you hover over it

.background {
  background: #222;
}
.link {
  color: #fff;
}
.link::-moz-selection {
  background: #f00;
  color: #0f0;
}
.link::selection {
  background: #f00;
  color: #0f0;
}
a:focus,
a:hover,
a:active {
  background: red;
  color: green;
}
<div class="background">
  <a class="link" href="https://app.tomvote.com/result/3a13bac6a6f93fa4fff0036bb1e8b7b5">Show Vote Results</a>
</div>
Rachel Gallen
  • 27,943
  • 21
  • 72
  • 81