如何使:: selection背景不透明度为1? [英] How to make ::selection background opacity: 1?

查看:89
本文介绍了如何使:: selection背景不透明度为1?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能吗?我希望所选文本具有纯色背景,而不是透明背景. opacity: 1不会这样做,因为浏览器必须有一个标准的替代项(或类似的东西).

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>

推荐答案

只需在::selection上使用background-color: rgba(255,255,255,0.99);尝试,它就会起作用:

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

http://jsfiddle.net/Hc25u/

这篇关于如何使:: selection背景不透明度为1?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆