什么是在句子中更改单个单词或一组单词的颜色或字体的正确方法?我正在使用Twitter Bootstrap,并希望继承
类的所有属性,但仅略微调整它们。
按照Chords的评论所说,您可以创建一个<span>
标签来包围您想要更改的文本。 您可以轻松地将多个类添加到单个以实现所需的外观。
这里是一个示例,展示了如何在单个上使用多个类。
CSS
.bold { font-weight: bold; }
.red { color: #FF0000; }
.yellow-background { background-color: Yellow; }
HTML
Here is <span class="bold">some text</span> that we are going to apply
<span class="bold red">different styles</span> to. You can see how
<span class="bold yellow-background">multiple classes</span> can be used to
change the <span class="red bold yellow-background">look and feel</span>
of the text.