本文介绍了使用 Twitter Bootstrap,如何自定义一个页面的 h1 文本颜色并将其他页面保留为默认值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

On my index page, I want the h1 text color to be white and comes with shadow, but I don't want to change the default behavior the h1 on other pages. How can I achieve this?

推荐答案

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

You can add your own id or class to the body tag of your index page to target all elements on that page with a custom style like so:

<body id="index">
   <h1>...</h1>
</body>

然后你可以像这样使用你的类或 id 来定位你想要修改的元素:

Then you can target the elements you wish to modify with your class or id like so:

#index h1 {
   color:red;
}

这篇关于使用 Twitter Bootstrap,如何自定义一个页面的 h1 文本颜色并将其他页面保留为默认值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 19:34