为什么使用 Chrome 在 GitHub 网站上看不到文本选择?

问题描述 投票:0回答:1

Firefox 和 Edge 没有这个问题

因此,对于 Chrome,当我尝试选择文本时,文本确实被选中但不可见,我的意思是文本背景不会改变。其他网站好像没问题。只有 GitHub 网站是这样的。

我认为这是 GitHub 网站的一个错误,因为阻止更改文本背景的 CSS 样式来自 GitHub 服务器。

请看视频: https://www.youtube.com/watch?v=HA1gmRHvbWs

css google-chrome github sass textselection
1个回答
1
投票

临时解决方案是在开发工具控制台窗口中运行这段代码:

const addStyle = (styleString) => {
  const style = document.createElement('style');
  document.head.append(style);
  style.textContent = styleString;
};

addStyle(`
  body *::selection {
    background-color: rgb(50 80 90 / 0.5) !important;
  }
`);

是的,每次刷新页面,我们都得重新运行这段代码。这只是一个快速的临时解决方案。

© www.soinside.com 2019 - 2024. All rights reserved.