css - 在 CSS 中使用::first-letter 时,Personalized::selection 不起作用

标签 css

我现在正在学习 CSS 基础知识,我在测试页面上发现了一些奇怪的东西。我正在写下 ::first-letter::first-line 的用法,出于习惯,我选择了全部。由于某种原因,当选择第一个单词时,我的 ::selection 个性化缺失。更奇怪的是,这只是一封信。一瞬间我想这可能是因为我将字体粗细设置为粗体,但其他粗体字母工作得很好。

::selection{
    background-color: #8ebacc;
    color: black;
}

#first::first-letter{
    font-size: 30px;
    color: black;
    font-weight: bold;
}

#first::first-line{
    font-variant: small-caps;
    font-size: 20px;
}
<p id="first">Here I wrote a lot of text. This first line is very fancy, and even fancier is the first letter. This is to give some emphasis to everything there, to establish that that is indeed the first line of this paragraph. </p>

发生什么事了?我该如何修复它?

最佳答案

在 chrome 中使用 ::first-letter 和 ::selection 无法正常工作。这是一个已知错误,已经由 chrome 开发人员提出,但尚未修复。

如果您可以使用 firefox,您可以考虑使用 ::mox-selection,这在 Mozilla firefox 中应该可以正常工作。

You can follow the developments and update: https://bugs.chromium.org/p/chromium/issues/detail?id=17528

关于css - 在 CSS 中使用::first-letter 时,Personalized::selection 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63083682/

相关文章:

javascript - 如何创建一个简单的表单并将其中一个字段传递给另一页中的脚本

javascript - 模态图片库 - 多张图片

html - 如何使用CSS在圆圈外添加图标?

html - 隐藏在 ul 上的溢出导致跳转

html - Column flexbox : wrap to width limit, 然后增长高度?

javascript - 使用 flex 布局,页脚不会完全下降到底部

html - 父高度为 auto 时高度 100%

jquery - 为什么 Stellar.js 中的元素不动?

css - 调整 HTML 电子邮件以在不同客户端呈现相同内容

html - 输入字段的大小可以设置为百分比值吗?