CSS:根据后备字体设置字体重量 [英] CSS: set font weight depending on fallback font

查看:131
本文介绍了CSS:根据后备字体设置字体重量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图根据所选择的字体设置元素的font-weight。例如,我可能试图做这样的事情:

I am trying to set the font-weight for an element based on the font that gets chosen. For example, I may be trying to do something like this:

h1 {
    font-family: Arial Narrow, Impact, sans-serif;
    font-weight: ?;
}

假设我想要font-weight为bold在他们的系统上安装了Arial Narrow,但如果浏览器必须使用Impact,则为正常,如果用户的系统没有这些字体,则可能为bold。这可能吗?

Let's say I want the font-weight to be "bold" if the user has Arial Narrow installed on their system, but "normal" if the browser has to use Impact, and maybe "bold" if the user's system has neither of those fonts. Is this possible? If so, how would I go about doing this?

推荐答案

我是99.99999%确定这不可能没有一些严重的JavaScript魔法,甚至使用JavaScript,都难以找到最后使用的字体。

I'm 99.99999% sure this can't be done without some serious JavaScript magic, and even with JavaScript it's damn difficult to find out which font was used in the end.

相关:在JavaScript中计算字体家庭您的真实需求

这篇关于CSS:根据后备字体设置字体重量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆