css - 如何使波浪下划线延伸覆盖Chrome中的所有字符
问题描述
我尝试使用波浪下划线来突出显示完整的句子,但它似乎会遗漏某些字符(短字符和下划线末尾的字符)。这是预期的行为还是 Google Chrome 中的错误(在 Firefox 中一切正常)?
如果这是预期的行为(我知道非常短的字符的波浪下划线可能看起来不太吸引人),我如何解决这个问题以在整个文本范围内获得波浪下划线(最好不求助于背景图像替代品)?
.dotted,
.wavy {
text-decoration-skip-ink: none;
text-decoration-line: underline;
text-decoration-color: blue;
}
.dotted {
text-decoration-style: dotted;
}
.wavy {
text-decoration-style: wavy;
}
div {
font-family: "Times New Roman"
}
div {
border: 4px solid black;
margin: 5px;
padding: 0px 5px;
}
.ok {
border-color: green
}
.problem {
border-color: red
}
.using-sans {
font-family: sans
}
<div class=ok>
<p>
The dotted underline correctly underlines all characters:
<span class=dotted>works ok</span>
</p>
<p>
As well as single characters:
<span class=dotted>d</span>
</p>
</div>
<div class="problem">
<p>
But the vawy underline misses the last character:
<span class=wavy>does not work ok</span>
</p>
<p>
And does not work for some single characters:
<span class=wavy>d</span>
</p>
</div>
<div class="ok">
<p>
Suprisingly, it does work for others:
<span class=wavy>W</span>
</p>
</div>
<div class="problem">
<p>
Which seem to depend on the length of the glyph, as the lowercase version of "w" does not work:
<span class=wavy>w</span>
</p>
</div>
<div class="ok using-sans">
<p>
Unless we change the font:
<span class=wavy>w</span>
</p>
</div>
<div class="problem using-sans">
<p>
But again, it will only work for some characters:
<span class=wavy>p</span>
</p>
</div>
编辑:我发现似乎是一个相关的错误报告,它解释了这一点
渲染波浪下划线的 Chromium 实现是“向下舍入到最接近的波长”
解决方案
推荐阅读
- javascript - 如何通过 vue 路由器将对象作为道具传递
- python - 连续两次调用 cursor.execute() 会产生不一致的结果
- php - 401 Unauthorized 尝试调用谷歌云功能时
- python - 如何仅修补 django rest 框架中嵌套序列化程序的外键?
- c++ - 为什么 Sublime Text 不执行我的程序?编译器问题?
- javascript - 在 Android Studio MainActivity4 中无法打开
- html - 为表格列添加样式
- php - Laravel validate() 方法在 false 时返回 index html 页面
- git - 为什么在 Windows 中使用“git bash”时,它与在 Windows 中打开“wsl Ubuntu”时看起来不一样?
- c# - 是否有在 C# (Unity) 中编写异步委托的优雅解决方案