Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css to remove text shadow on select / highlight text (mozilla)

I'm using text shadows for most text site wide, but when you highlight / select the text - the text looks fuzzy. So in order to remove the text shadow I use this css from here.

::-moz-selection,
::-webkit-selection,
::selection {
    text-shadow: none;
    background: #333;
    color: #fff;
}

The problem is that for some reason moz-selection doesn't seem to work (anymore?) in mozilla (Firefox).

Here's the jsFiddle

like image 289
Danield Avatar asked Oct 23 '12 09:10

Danield


People also ask

Which feature is to add shadow behind the selected text?

Select the text or WordArt that you want to format. On the Format tab, under Text Styles, click Effects, point to Shadow, and then click the shadow style that you want.

What is CSS text shadow?

The text-shadow CSS property adds shadows to text. It accepts a comma-separated list of shadows to be applied to the text and any of its decorations . Each shadow is described by some combination of X and Y offsets from the element, blur radius, and color.

What is drop shadow CSS?

CSS Demo: drop-shadow() A drop shadow is effectively a blurred, offset version of the input image's alpha mask, drawn in a specific color and composited below the image. Note: This function is somewhat similar to the box-shadow property.


1 Answers

It seems like the problem was due to grouping multiple css rules (for the vendor specific css) together in conjuntion with the ::selection pseudo element.

I originally thought that it was sufficient to write each statement on a separate line.

I was mistaken.

So if I replace this code:

::-moz-selection,
::selection {
    text-shadow: none;
    background: #333;
    color: #fff;
}

..With this code:

::-moz-selection
{
    text-shadow: none;
    background: #333;
    color: #fff;
}
::selection {
    text-shadow: none;
    background: #333;
    color: #fff;
}

.... bingo, it works.

FIDDLE

Support is also very good (for desktop): Caniuse

Also, if you use LESS or SASS - you could easily write a mixin to get around the repitition.

like image 187
Danield Avatar answered Nov 16 '22 02:11

Danield