2012-11-27 109 views
8

更改语句中单个单词或一组单词的颜色或字体外观的正确方法是什么?我正在使用Twitter Bootstrap并希望继承<div>的课程的所有属性,但只能稍微调整它们。如何更改字体颜色mid-sentence

回答

11

要取消Chords评论,您可以创建一个围绕您要更改的文本的<span>标记。您可以轻松地将多个课程添加到单个跨度,以实现您想要的外观。

这里的a fiddle显示如何在单个跨度上使用多个类。

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.​ 
+0

宾果!这就是我所追求的。我会把这一个给杰森,但支持和弦建议这种方法。干杯。 – dugla

+0

呵呵,+1的小提琴凉爽。 – dugla

+0

刚刚发现这一点,并不能相信我以前没有想过它。 –