如何在Jumbotron Bootstrap 3中更改字体粗细?

3

如何更改.jumbotron.jumbotron中的段落字体粗细?我不想让我的font-weight太大。

HTML:

<header>
    <div class="container-fluid landing-page">
        <div class="jumbotron vertical-center">
            <h1>Embroider<span class="eze">eze</span></h1>
            <p>Branding <span class="eze">&#9679;</span> Promotional Items <span class="eze">&#9679;</span> Reflective Tape <span class="eze">&#9679;</span> Gifts</p>
        </div>
    </div>
</header>

CSS(层叠样式表):
.jumbotron {
    color: #dbdbdb;
    background-color: transparent;
    text-align: center;
    margin-top: 300px;
    font-weight: 200;
}

此��,字体大小更改不起作用。

https://jsfiddle.net/pa07so3e/。对我来说,它似乎按预期工作。我将`font-weight: 900`进行了修改以说明它的变化。这个Fiddle:https://jsfiddle.net/pa07so3e/1/ 显示更小的字体。 - user2796515
可能是我链接的CSS有问题,我会检查一下。(编辑)还是不行 - CSS链接正确。 - Wihan Uys
@user2796515 看起来这些图片中字体的粗细并没有改变,只有字体大小改变了。 - Wihan Uys
这个例子中h1p标签已经被修改:https://jsfiddle.net/pa07so3e/3/ 与此相比:https://jsfiddle.net/pa07so3e/4/ - user2796515
3个回答

1

更新Bootstrap 4 Jumbotron中字体粗细的调整:

类似语法 - 假设您在css文件中创建以下类:

   .jumbotron_text { font-weight: 600; }

并将其应用于以下方式的 jumbotron div 内部的 p 标签;

    <div class="jumbotron">
      <p class=jumbotron_text">Some text here </p>
    </div>

请注意,我使用了600(范围是100、200、300、400、500、600、700、800、900)。

大多数字体将普通字重映射为500,将加粗字重映射为700。

除非字体中明确提供,否则其他数字是浏览器的近似值。


1

you can check this:

<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title></title>
  <meta name="description" content="">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

  <!-- jQuery library -->
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

  <!-- Latest compiled JavaScript -->
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <style>
    .jumbotron h1 {
      color: #dbdbdb;
      background-color: transparent;
      text-align: center;
      margin-top: 100px;
      font-weight: 200;
      font-size: 20px;

    }

    .jumbotron p {
      color: #dbdbdb;
      background-color: transparent;
      text-align: center;
      margin-top: 100px;
      font-weight: 200;
      font-size: 20px;

    }
  </style>
</head>

<body>
  <!--[if lt IE 7]>
        <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
      <![endif]-->
  <header>
    <div class="container-fluid landing-page">
      <div class="jumbotron vertical-center">
        <h1>Embroider
          <span>eze</span>
        </h1>
        <p>Branding
          <span>&#9679;</span> Promotional Items
          <span>&#9679;</span> Reflective Tape
          <span>&#9679;</span> Gifts</p>
      </div>
    </div>
  </header>
</body>

</html>


1

默认情况下,Bootstrap 对 h1 和 P 元素有一些样式。如果您想覆盖这些样式,请尝试使用以下方法。

.jumbotron h1{

font-weight: 800;

}

.jumbotron p{

font-weight: 800;

}

看起来这好像可行,但我的文本在字重为 100 到 500 的范围内没有改变。 - Wihan Uys
@WihanUys 尝试增加字体大小。 - PDSSandeep

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接