我可以根据字体可用性设置字体大小吗?
是否可以根据字体可用性设置不同的字体大小?
目前我的问题是 Verdana
太大,如果用户没有安装 Verdana
,我最终会得到一个非常小的字体大小
是否有将字体(在我的例子中为 Verdana)设置为 13px 的方法,如果用户没有安装该字体,请尝试使用其他字体(例如 Arial),但使用更大的字体大小?
注释:
- 最好只
- 允许 CSS CSS hacks
Is it possible to set a different font-size according to font availability?
Currently my problem is that Verdana
is too big, and if the user don't have Verdana
installed, I will end up with a very small font-size
Is there is any way to set a font (Verdana
in my case) to 13px and if the user don't have that font installed, try with another font (Arial
for example) but with bigger font-size?
Notes:
- Preferably CSS only
- CSS hacks allowed
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如其他人在一分钟前回答的那样(但已经删除?),您可以使用 字体检测器 JavaScript 解决方案:
http://jsfiddle.net/FHnJw/1
As was answered just a minute ago by someone else (but already deleted?), you could use Font Detector Javascript solution:
http://jsfiddle.net/FHnJw/1
这可能需要一些工作来实现(我自己实际上还没有这样做过),但似乎
font-size-adjust
属性通过标准化 x 高度来帮助“均衡”字体。请参阅http://www.w3.org/TR/css3 -fonts/#propdef-font-size-adjust 获取官方说明。This might take some work to implement (I have not ever actually done it myself), but it seems that the
font-size-adjust
property helps "equalize" font's by standardizing the x-height. See http://www.w3.org/TR/css3-fonts/#propdef-font-size-adjust for the official description.字体大小调整仅适用于 Firefox
独立的“font”css 声明仅允许您在连续声明不同的字体系列之前声明一次字体大小、样式和粗细,所以这是不行的
我很遗憾地说无法单独通过 css 完成
至于 JS 替代方案,这是我推荐的替代方案:
http://www.lalit.org/lab/javascript-css-font-detect/
祝你好运
Font-size adjust only works with Firefox
The standalone 'font' css declaration only allows you to state font-size, style and weight once before declaring the different font families in succession so that's a no-go either
I'm sorry to say this cannot be done through css alone
As for the JS alternative, here's the one I recommend:
http://www.lalit.org/lab/javascript-css-font-detect/
Good luck