使用Twitter Bootstrap,如何自定义一页的h1文本颜色并将其他页面保留为默认值?

tom*_*tom 21 textcolor twitter-bootstrap

在我的索引页面上,我希望h1文本颜色为白色并带有阴影,但我不想在其他页面上更改h1的默认行为.我怎样才能做到这一点?

Con*_*ech 104

在bootstrap 3中这里是更改文本颜色的类:

<p class="text-muted">...</p> //grey
<p class="text-primary">...</p> //light blue
<p class="text-success">...</p> //green
<p class="text-info">...</p> //blue
<p class="text-warning">...</p> //orangish,yellow
<p class="text-danger">...</p> //red
Run Code Online (Sandbox Code Playgroud)

帮助程序类下的文档- 上下文颜色.

  • 接受答案的更好的解决方案.侧链接:http://getbootstrap.com/css/#helper-classes (5认同)

And*_*ich 23

您可以将自己的id或类添加到索引页的body标记,以使用自定义样式定位该页面上的所有元素:

<body id="index">
   <h1>...</h1>
</body>
Run Code Online (Sandbox Code Playgroud)

然后,您可以使用您的类或ID定位要修改的元素,如下所示:

#index h1 {
   color:red;
}
Run Code Online (Sandbox Code Playgroud)

  • 是否有这个功能的内置类 (2认同)

sk8*_* ツ 8

您还可以应用bo​​otstrap本身提供的默认"文本"类

 <h1 class='text-info'>Hey... I'm blue</h1>
Run Code Online (Sandbox Code Playgroud)

http://twitter.github.io/bootstrap/base-css.html