html - CSS - 字体在具有更高 dpi 的设备上显得更粗

标签 html css

我一直在不同的设备上测试我的网页,文本在设备像素比较高的设备(例如 iPhone)上显得更粗。我也在 chrome 模拟器上对此进行了测试:文本在 DPR 1 下看起来很完美,在 DPR 2 下显得更粗。

在 DPR 1

enter image description here

AT DPR 2

enter image description here

有什么方法可以修复或减少这种影响吗?任何帮助将不胜感激。

HTML:

<div class="section" id="section3">
  <h1>Projects</h1>
</div>

CSS:

/*to fix safari bold font*/
h1, h2, h3, h4, h5, strong, b {
  font-weight: 400;
}

#section4 h1,#section3 h1 {
  visibility: hidden;
  position: absolute;
  font-family: Graphik-Semibold, Roboto;
  font-weight: 600;
  margin: 0;
  top: 3.7%;
}

这是最相关的代码,其余的是对齐和媒体查询字体大小。

最佳答案

@media only screen and (max-device-pixel-ratio: 2) {
  b {
    font-weight: 600;
  }
}

@media only screen and (min-device-pixel-ratio: 2) {
  b {
    font-size: 400;
  }
}

您可能需要更改一些数字以获得您想要的结果,这只是一个示例。

据我所知,实际上没有任何其他方法可以做到这一点,因为即使数字相同,字体粗细也总是不同的。另外,在 DPR 2.0 上并没有太大的区别

看起来不错:)

关于html - CSS - 字体在具有更高 dpi 的设备上显得更粗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46863948/

相关文章:

javascript - html输入数字,min + step,使step忽略min?

javascript - 如何计算选中的复选框数、选中后更改背景以及悬停继续工作

css - 避免在溢出 : hidden for fixed width/height container 的多行文本中切割线

jquery - 如何切换 "a"标签元素以显示隐藏的 DIV,就像 Facebook 通知中心一样

javascript - iframe 完成加载后加载指示器保留在 Firefox 中

html - 你怎么能让 Bootstrap 3 选项卡上的文本溢出?

javascript - 对有关脚本标签类型属性的特殊 JavaScript 问题感到好奇

html - Firefox 和 Chrome 中的文本区域填充不一致

css - 针对特定案例调整 UI-ICON-SEARCH 的高度

jquery - 在旋转木马的图像部分周围添加边框