:: choice of background color and color rendering in browsers

Problem

Using the following simply does not work properly in browsers -webkit-and -moz-:

#exampleElement {
    background-color: red; /* For example */
}

#exampleElement ::selection {
    color: black;
    background-color: white;
}

 

Result: browsers with WebKit and Blink support

Chrome, Opera, and Safari ::selection background-colordisplay as if it were 50% alpha, but the font color is correct.

Chrome 29.0.1547.62:
Chrome 29.0.1547.62

Opera 15.0.1147.130:
Opera 15.0.1147.130

Safari 5.34.57.2:
Safari 5.34.57.2

 

Result: Gecko-enabled browsers

In Firefox, the complete rule is ::selectionignored. ::selection background-colorjust happens to be white due to #exampleElementdark background-color(thanks to @BoltClock for this remark)

Firefox 22.0:
Firefox 22.0

 

Result: Trident-enabled browsers

In Internet Explorer (you would believe) everything is done perfectly.

Internet Explorer 10.0.9200.16660:
Internet Explorer 10.0.9200.16660

 

/ -webkit- -moz-, ?

jsFiddle, : http://jsfiddle.net/BWGJ2/

+5
2

quirksmode.org, -webkit-selection -moz-selection . Chrome (18) Firefox (13) , Firefox, -webkit-selection Chrome ( ) SO ( , ::selection , ).

, Chrome , ,

background:rgba(255, 255, 255, 0.99);

. tw16


, FF:

::selection { /* stuff */ }
::-moz-selection { /* stuff */}

:

::selection, ::-moz-selection { /* stuff */ }

, , ::selection, , .

+3

. , , CSS3, . ...

- , : CSS ID " " , CSS . !important ::selection, , , .

, !

0

All Articles