如何使:: selection背景不透明度为1? [英] How to make ::selection background opacity: 1?
本文介绍了如何使:: 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:
这篇关于如何使:: selection背景不透明度为1?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文