草庐IT

html - 为什么设置 :first-letter selector with whitespace cause mouse highlighting to be offset?

coder 2023-08-12 原文

有一个问题,通过添加空格我得到以下突出显示的偏移量异常。这真的是预期的行为吗?

这似乎影响了 Chrome/Safari

问题重现于此:https://jsfiddle.net/qsa99cc6/

CSS:

p:first-letter {
    text-transform: uppercase;
}

HTML:

<p>
         highlight me! this won't work because there's whitespace in the &lt;p&gt;
</p>

<p>highlight me! This should work because there isn't</p>

最佳答案

它的行为在不同的浏览器上是不同的。所以它也可能是浏览器中的某种错误。也许那些浏览器识别伪元素 :first-letter 的方式与伪元素 :before:after 相同。

关于html - 为什么设置 :first-letter selector with whitespace cause mouse highlighting to be offset?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32990392/

有关html - 为什么设置 :first-letter selector with whitespace cause mouse highlighting to be offset?的更多相关文章

随机推荐