gpt4 book ai didi

css - 在 Firefox 中更改非事件选择颜色

转载 作者:技术小花猫 更新时间:2023-10-29 11:19:20 25 4
gpt4 key购买 nike

当我在 Firefox 中选择一些文本然后窗口或 Iframe 失去焦点(例如选择地址栏)时,即使在 css 中指定了不同的颜色,选择也会变成灰色。

如何在 Firefox 中更改已禁用选择的颜色?

我尝试过的:

<style>::selection { background-color: green; }</style>
<p>lorem ipsum</p>

Screenshot of the Behavior

编辑:

我想在这里使用的似乎是::inactive-selection,但它还没有在firefox中实现。参见 https://drafts.csswg.org/css-pseudo-4/#selectordef-inactive-selection

相关错误:https://bugzilla.mozilla.org/show_bug.cgi?id=706209

有人知道解决方法吗?在这一点上,我正在考虑使用一些 javascript hacks。任何想法如何做到这一点?

最佳答案

不,你不能

至少在 Firefox 上不是。

我之所以回答,是为了节省您的时间和其他可能试图找到一些解决方案/技巧的人。

因为您已经了解了 css 规范。我可能想补充一点,

Remember Firefox has it's own version of ::selection, ::-moz-selection. It also has it's own version of :window-inactive, :-moz-window-inactive. Unfortunately using these things together doesn't work.

Source: CSS Tricks

/* Does work */
::-moz-selection {
background: rgba(255,0,0,0.9);
color: white;
}
/* Doesn't work */
::-moz-selection:-moz-window-inactive {
background: rgba(255,0,0,0.3);
}
/* Nor this */
:-moz-window-inactive::-moz-selection {
background: rgba(255,0,0,0.3);
}

此外,Bugzilla 有多年的错误要求此功能并谈论它无法处理非事件选择但没有回应。这是一个list .其中一些甚至只有 11 岁。我打算与某人讨论这个问题,并自己报告一个新错误并提供更多详细信息,可能会在此处添加他们的回复或错误编号,以便您可以获得更新。

因此,目前我认为您不应该寻找一些 hack,这只会浪费您的时间。

谢谢

更新:这里是 bug关注 bugzilla,让我们看看开发团队有什么要说的。

关于css - 在 Firefox 中更改非事件选择颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56514591/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com