LoginSignup
1
1

More than 5 years have passed since last update.

【CSS】HTMLページの文字選択時の背景色・文字色(反転色)を変更する方法

Last updated at Posted at 2017-10-12

HTMLページの文字選択時の背景色・文字色(反転色)を変更する方法についてです。

<設定前>(ブラウザの標準設定)
設定前

<設定後>
設定後
 
次のようにCSSを記述します。

<style type="text/css">
<!--
::selection {
    background: #fad7d7; /*背景色*/
    color: #ffffff; /*文字色*/
}
::-moz-selection {
    background: #fad7d7; /*背景色*/
    color: #ffffff; /*文字色*/
}
-->
</style>

-moz-selectionはFirefox用です。 文字色は設定しなければ元のままの色ととなります。 (上の画像は文字色は未設定です)

 
ブログ(creativi.tea)では他にもいろいろと掲載していますので、ご覧くださいね。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1