让页面的字体变得更清晰(css 实现)
css3 属性 -webkit-font-smoothing
对字体进行抗锯齿渲染可以使字体看起来会更清晰舒服。在图标字体成为一种趋势的今天,抗锯齿渲染使用也越来越多。font-smoothing
是非标准的 CSS 定义。它被列入标准规范的草案中,后由于某些原因从 web 标准中被移除了。但是,我们可以用以下两种定义进行抗锯齿渲染
Webkit 在自己的引擎中支持了这一效果。
-webkit-font-smoothing
它有三个属性值:
- none:对低像素的文本比较好
- subpixel-antialiased:默认值
- antialiased:抗锯齿很好
具体代码
css
.content {
-webkit-font-smoothing: antialiased;
}
-moz-osx-font-smoothing: inherit | grayscale;
这个属性也是更清晰的作用。
具体代码
css
.content {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}