html - CSS 链接下划线在某些浏览器中太粗

标签 html css cross-browser google-fonts

我的链接设置为“font-weight 300”和“text-transform underline”。我通过 @import 使用 Google 字体“Roboto”。在 Chrome 和 Opera 中,下划线很粗,如 font-weight 400。FF、Edge 和 IE 没有这个问题。

HTML:

<p><a href="index.html">Zurück</a></p>

SCSS:

@import url('https://fonts.googleapis.com/css?family=Roboto:300');

@mixin font-family-sans-serif(){  
  font-family: 'Roboto', sans-serif;
  font-weight: 300;
}

a, 
a:hover, 
a:link, 
a:visited, 
a:active, 
a:focus,
button{
  text-decoration: none;
  &:hover, &:focus{
    text-decoration: underline;
  }
}

悬停时FF中没有问题:

enter image description here

Chrome 中悬停时出现的问题:

enter image description here

有人知道如何解决这个问题吗?

最佳答案

我经常发现 Roboto 渲染下划线以接近文本。在大多数情况下我不喜欢(主要是在较小的字体大小上)。

我通常使用边框或框阴影。您还可以考虑使用透明颜色或子像素(Chrome 在渲染子像素方面做得很好)厚度来调整外观。

但这取决于您所针对的浏览器支持。一些例子可以给你一个想法。

带有 box-shadow 的 SCSS 示例:

$link-color: #0e7aef;

a {
    padding-bottom: 1px; // Distance of 'line' from link text adjust accordingly
    font-family: 'Roboto', sans-serif;
    text-decoration: none;

    &:focus,
    &:hover {
        box-shadow: 0 1px 0 rgba($link-color, 0.8);
        // box-shadow: 0 0.75px 0 $link-color; // sub-pixel example
    }
}

关于html - CSS 链接下划线在某些浏览器中太粗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48833864/

相关文章:

css - div 内的整个区域未链接

javascript - 将 Uint8Array 保存到二进制文件

internet-explorer-8 - IE 8 Doc 模式 - &lt;meta http-equiv ="x-ua-compatible"content ="IE=8"> 的优缺点

html - 如何在 bootstrap 中将 2 个图像居中

html - 一切都散布在我的网站上

jquery - 使用 jQuery 更改重叠图像的 z-index

javascript - 动态添加行到表体

javascript - 如何根据密码强度显示自定义消息

firefox - 测试不同版本的非IE浏览器

html - 表格html底部从右到左的滚动条