How to make ::selection background opacity: 1?

梦想与她 提交于 2020-01-03 10:54:08

问题


Is this possible? I want selected text to have a solid background, not a transparent background. opacity: 1 does not do it because there must be a standard override from the browser (or something like that).

::-moz-selection {
  background: #fff;
  color: #000;
}

::selection {
  background: #fff;
  color: #000;
}

body {
  color: #fff;
  font-family: sans-serif;
  line-height: 2em;
}

div {
  padding: 2em;
  background: #F8372A;
  text-align: center;
}
<div>
  <h1>HEY!</h1>
  <p>why is my background not<br/><strong>STARK WHITE</strong><br/>when selected?</p>
</div>

回答1:


Just tried with background-color: rgba(255,255,255,0.99); on ::selection and it works:

http://jsfiddle.net/Hc25u/



来源:https://stackoverflow.com/questions/22751624/how-to-make-selection-background-opacity-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!