[CSS] 改變選取文字的顏色


One of those cool CSS3 declarations that you can use today is ::selection, which overrides your browser-level or system-level text highlight color with a color of your choosing.

::selection {
    background: #ffb7b7; /* Safari */
}
::-moz-selection {
    background: #ffb7b7; /* Firefox */
}

::selection {
    color: inherit; /* Safari */
}
::-moz-selection {
    color: inherit; /* Firefox */
}

補充:更改input輸入框提示字顏色

input::placeholder {
  color: pink;
}
input::-moz-placeholder { /* Firefox 19+ */
  color: pink;
}
input:-moz-placeholder { /* Firefox 18- */
  color: pink;
}
input:-ms-input-placeholder { /* IE 10+ */
  color: pink;
}
input::-webkit-input-placeholder { /* Chrome/Opera/Safari */
  color: pink;
}

CSS-Tricks ::placeholder

Source

Tsung's Blog

Image Source

CSS: How To Change Default Text Selection Color on your Blog

沒有留言:

技術提供:Blogger.