简体   繁体   English

虚线下划线无法在Chrome中正确呈现

[英]Dotted underlines don't render properly in Chrome

Using Chrome 65, it looks like the text-decoration: underline dotted; 使用Chrome 65,它看起来像text-decoration: underline dotted; yields an unelegant result : 产生一个不雅的结果:

在此输入图像描述

Whereas on Firefox, i'm getting the expected outcome : 而在Firefox上,我得到了预期的结果:

在此输入图像描述

What's wrong with chrome ? 铬有什么问题?


I expanded the snippet with a further test. 我通过进一步测试扩展了片段。 It seems to only fail with certain font sizes and font faces. 似乎只有某些字体大小和字体表面失败。 Specifically here with Trebuchet MS and 18px font-size. 特别是在这里使用Trebuchet MS和18px字体大小。

 span{ text-decoration: underline dotted; font-family: Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif; padding: 1rem; background-color: black; color: white; display: inline-block; margin: 1rem; } 
 <span style="font-size: 12px;"> A 12px button of some sort </span> <span style="font-size: 14px;"> A 14px button of some sort </span> <span style="font-size: 16px;"> A 16px button of some sort </span> <span style="font-size: 18px; background-color: darkRed;"> A 18px button of some sort </span> <span style="font-size: 20px;"> A 20px button of some sort </span> 

Use text-decoration-skip-ink: none (The default was changed to auto in https://crrev.com/514104 .) 使用text-decoration-skip-ink: none (默认值已在https://crrev.com/514104中更改为auto 。)

If you look closely, the gaps in the underline correspond to the loops at the bottom of the letters, which lie very close to the baseline of the font. 如果仔细观察,下划线中的间隙对应于字母底部的环,它们非常接近字体的基线。 It appears that the skip-ink algorithm is choosing to cut the underlines off here — but only for dotted and dashed, and only at certain font sizes. 似乎skip-ink算法选择在此处删除下划线 - 但仅限于虚线和虚线,并且仅限于某些字体大小。

https://crbug.com/808603 suggests that the underlying reason is that the dots and dashes are two pixels tall. https://crbug.com/808603表明,根本原因是点和短划线是两个像素高。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM