本来想通过Google搜索得到答案,但是我感觉组织不好语言。于是来这里了。
html部分代码如下:
<li>
This is a nice world.
<pre>
I don't want to be bold!
</pre>
<div>....</div>
.... <!-表示许多不同种类的标签-->
</li>
我现在需求是只让 This is a nice world
加粗,但是 <pre>
中的内容字体不被加粗。
这个能够使用CSS直接来控制么?还是需要使用js来修改。我的想法是最好是使用纯CSS实现。
麻烦各位回答啦,谢啦:)
如果这样的话,可否在 This is a nice world. 外面加个p标签
<p class="bold_word">This is a nice world. </p>
然后css改成这样
li p.bold_word {
font-weight: bold;
}
试试这个?
li { font-weight: bold; }
li > * { font-weight: normal; }