更改 CSS“粗体”属性 font-weight 值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18379851/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 00:03:25  来源:igfitidea点击:

Change CSS "bold" property font-weight value

csstwitter-bootstrap

提问by Augustin Riedinger

The question is pretty straightforward.

这个问题很简单。

I use Bootstrap, where all the bold things are CSSized in

我使用 Bootstrap,其中所有粗体都在 CSSized 中

tag {
  font-weight: bold;
}

but I use Open Sans(as so many people), where font-weight: 400is not enough and font-weight: 700is much better.

但我使用Open Sans(因为这么多人),哪里font-weight: 400还不够,font-weight: 700而且好多了。

Is there a way I tell my CSS that bold=700and not 400 (which is I reckon the default value) ?

有没有办法告诉我的 CSSbold=700而不是 400(我认为这是默认值)?

=====

======

EDIT

编辑

I must have been unclear.

我一定是不清楚。

In CSS only, without modifying Bootstrap sources, there are many locations (the whole list here) where bootstrap says (Eg.)

在 CSS 中,无需修改 Bootstrap 源,bootstrap 有很多位置(这里是整个列表)(例如)

h6 {
  font-weight: bold
}

I'd like the web-browser to understand that in this case boldshould be equivalent to font-weight: 700instead of font-weight: 400as per default without rewriting all the rules (Eg.)

我想网络浏览器要明白,在这种情况下,bold应该是相当于font-weight: 700而不是font-weight: 400按默认无需重写所有的规则(如)

h6 {
  font-weight: 700
}

The answer can be that it is not currently possible, but Google hasn't provided me any answer yet.

答案可能是目前不可能,但谷歌还没有给我任何答案。

回答by Kami

if you are using the strongtag.

如果您正在使用strong标签。

strong {
    font-weight: 700;
}

or if you are making elements bold using font-weight:bold, why not

或者,如果您使用 使元素加粗font-weight:bold,为什么不

elem {
    font-weight: 700;
}

Note: As @Pavlo pointed out, bold is equivalent to 700.

注意:正如@Pavlo 指出的,粗体相当于 700。

回答by Doidgey

If you are using Open Sans, i would guess you are using @fontface- It's not advisable to set font-weight's using the font-weight property while using @fontfaceunless from something like Typekit. If your hosting your own fonts, i think adding font-weight will try and add a weight on a font that only has one weight.

如果您使用的是 Open Sans,我猜您正在使用@fontface- 不建议在使用时使用 font-weight 属性设置字体粗细,@fontface除非来自 Typekit 之类的东西。如果您托管自己的字体,我认为添加 font-weight 会尝试在只有一个权重的字体上添加权重。

Open sans i often use and i know comes in several weights all of which you reference in your style separately and call depending on what you need. So you would simply reference the opensans-boldor whichever weight you wanted.

Open sans 我经常使用,我知道有几种权重,所有这些权重都在你的风格中分别引用,并根据你的需要调用。因此,您只需参考opensans-bold您想要的重量或任何重量即可。

However using fonts from google etc, i think font weights do work.

但是使用谷歌等的字体,我认为字体权重确实有效。

A good article here

好文章在这里