使用Bootstrap类设置font-weight

时间:2013-09-30 11:38:29

标签: html css twitter-bootstrap twitter-bootstrap-3

是否有font-weight: bold的Twitter Bootstrap课程以及font-weight的其他值?

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

7 个答案:

答案 0 :(得分:88)

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

<strong>rendered as bold text</strong>

答案 1 :(得分:43)

Bootstrap 4

class="font-weight-bold"

或者:

<strong>text</strong>

答案 2 :(得分:35)

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

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

答案 3 :(得分:14)

编辑2(最终):根据the bootstrap 4 documentationclass="font-weight-bold"正是您要找的。

编辑:您可以将class="font-weight-bold"用作shown here(Bootstrap 4 alpha)。

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

我发布这个答案是因为这个帖子似乎有很多访问者,但它没有适当的解决方案来解决这个问题。但现在很快就会有一种Bootstrap 4的方式:

this GitHub pull request所示,您只需使用text-weight-normaltext-weight-boldtext-weight-italic类。

这可能会改变,直到官方稳定发布。在此撰写日期,此拉取请求尚未在alpha分支中合并。

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

答案 4 :(得分:7)

在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>

答案 5 :(得分:1)

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

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

答案 6 :(得分:0)

如果您在 Mac 版 Chrome 中检查此内容,我认为可能存在浏览器不兼容问题。

试试这个

* {-webkit-font-smoothing: antialiased;}