问题描述:

/* Site */

::-webkit-selection {

background-color: @highlightBackground;

color: @highlightColor;

}

::-moz-selection {

background-color: @highlightBackground;

color: @highlightColor;

}

::selection {

background-color: @highlightBackground;

color: @highlightColor;

}

I am using semantic-ui as css framework, and I have been overriding its values today. I came across with selection option, which is overridden by default, and I would like to set it as computer default. As some of you know, you can change selection color in macbooks, so I would like my users to use computer's default selection color.

So, what should I do? I tried inherit and transparent but they don't work.

网友答案:

The solution is to use the system color highlight for the background and highlighttext for the foreground.

Colors like inherit won't work, because inherit means "use the same color as the parent element". That's not what we want!

The first example sets the selection colors to yellow on brown, to emulate the framework theme. Just to make sure changing those colors works at all.

/* colours from theme */
::-webkit-selection {
  background-color: brown; color: yellow;
}
::-moz-selection {
  background-color: brown; color: yellow;
}
::selection {
  background-color: brown; color: yellow;
}
<div>This is a div in which you can make a selection</div>
相关阅读:
Top