Safari 的 CSS 问题 - 在 h1 内渲染链接,下划线不均匀
我有这样的事情
<h1>
<a href="/" title="Home">Home</a>
</h1>
非常简单。 IE、FF渲染流畅,下划线效果很好。 Safari 做了我以前从未见过的奇怪的事情,它仅在字体衬线和字体的位置强调“Home”。曲线不要接触下划线,即字母“H”会在两个“柱子”之间添加下划线(我知道听起来很奇怪),并且在这两个接触下划线的地方,后者的颜色会变得更浅(#eee 与 #000)。
更新: 显然,当出现此情况时,Safari 无法很好地呈现链接
text-shadow: 0px 2px 1px #fff;
是否有特殊原因?
I have something like this
<h1>
<a href="/" title="Home">Home</a>
</h1>
Very simple. IE, FF render it smoothly, underline works fine. Safari does this weird thing I've never seen before, it underlines "Home" only where the font serifs & curves DONT touch the underline, i.e. the letter "H" would get underline between the two "pillars" (sounds weird i know), and where those two touch the underline, the latter becomes much lighter in color (#eee vs #000).
UPDATE:
Apparently Safari's not rendering the link well when there's
text-shadow: 0px 2px 1px #fff;
Is there a particular reason for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
原因是因为文本阴影是在最前面的层渲染的。如果我是你,我会向 h1 a 元素添加一个无下划线的 border-bottom。
当然,将蓝色替换为链接的任何颜色。
编辑:意识到可以使用
span
标签来修复阴影。我认为使用投影时下划线和基线之间有一点空间看起来更好,但如果您必须有一个
text-decoration: underline
您必须在标记中添加一个 span 元素:CSS:
The reason is because the text-shadow is rendered on the frontmost layer. If I were you I'd add a border-bottom to the h1 a element with no text underline.
Of course, replace blue with whatever colour your links are.
Edit: Realized that the shadow could be fixed with a
span
tag.I think having a bit of space between the underline and the baseline when using the drop shadow looks better, but if you must have a
text-decoration: underline
you would have to add a span element to your markup:CSS: