Html 使用 Bootstrap 类设置字体粗细

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19093268/
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-29 13:58:10  来源:igfitidea点击:

Set font-weight using Bootstrap classes

htmlcsstwitter-bootstraptwitter-bootstrap-3

提问by Ionic? Biz?u

Is there any Twitter Bootstrap class for font-weight: boldand other values of font-weight?

是否有任何 Twitter Bootstrap 类font-weight: bold和其他值font-weight

I would not create a new one if this already exists in Bootstrap.

如果 Bootstrap 中已经存在,我不会创建一个新的。

采纳答案by Ilshidur

EDIT 2 (final) : According to the bootstrap 4 documentation, class="font-weight-bold"is what you are looking for.

编辑 2(最终):根据bootstrap 4 文档class="font-weight-bold"这就是您要查找的内容。



EDIT : You can use class="font-weight-bold"as shown here(Bootstrap 4 alpha).

编辑:您可以class="font-weight-bold"此处所示使用(Bootstrap 4 alpha)。

I kept the original answer below for clarity purposes.

为了清楚起见,我保留了下面的原始答案。



I am posting this answer because this thread seems to have a lot of visitors, yet it had no proper solution to solve this issue. But there will be soon now a way with Bootstrap 4 :

我发布此答案是因为此线程似乎有很多访问者,但它没有解决此问题的适当解决方案。但是现在很快就会有 Bootstrap 4 的方法:

As this GitHub pull requestshows, you will just have to use the text-weight-normal, text-weight-boldand text-weight-italicclasses.

如此 GitHub 拉取请求所示,您只需使用text-weight-normal,text-weight-boldtext-weight-italic类。

This can maybe change until the official stable release. At this date of writing, this pull request is not merged yet in the alpha branch.

这可能会在正式稳定版本发布之前发生变化。在撰写本文时,此拉取请求尚未合并到 alpha 分支中。

I will update this post once Bootstrap v4 has been released.

一旦 Bootstrap v4 发布,我将更新这篇文章。

回答by Brett Merrifield

I found this on the Bootstrap website, but it really isn't a Bootstrap class, it's just HTML.

我在Bootstrap 网站上找到了这个,但它确实不是 Bootstrap 类,它只是 HTML。

<strong>rendered as bold text</strong>

回答by Jeremy Lynch

In Bootstrap 4:

Bootstrap 4 中

class="font-weight-bold"

Or:

或者:

<strong>text</strong>

回答by Gurgen Hakobyan

Create in your Site.css (or in another place) a new class named for example .font-bold and set it to your element

在您的 Site.css(或其他地方)中创建一个名为 .font-bold 的新类并将其设置为您的元素

.font-bold {
  font-weight: bold;
}

回答by danramzdev

On Bootstrap 4 you can use:

在 Bootstrap 4 上,您可以使用:

<p class="font-weight-bold">Bold text.</p>
<p class="font-weight-normal">Normal weight text.</p>
<p class="font-weight-light">Light weight text.</p>

回答by maioman

You should use bootstarp's variables to control your font-weight if you want a more customized value and/or you're following a scheme that needs to be repeated ; Variables are used throughout the entire project as a way to centralize and share commonly used values like colors, spacing, or font stacks;

如果您想要更自定义的值和/或您遵循需要重复的方案,您应该使用 bootstarp 的变量来控制您的字体粗细;在整个项目中都使用变量作为集中和共享常用值(如颜色、间距或字体堆栈)的一种方式;

you can find all the documentation at http://getbootstrap.com/css.

您可以在http://getbootstrap.com/css 上找到所有文档。