2014-08-27 88 views

回答

4

當然,使用下面的CSS代碼:

em { 
    font-weight: bold; 
    font-style: normal; 
} 
+3

這個答案是正確的,爲什麼它被拒絕? – Devin 2014-08-27 19:58:50

+2

誰知道。可能是任何事 - 有人在做戰略性的投票來推動他們的回答;有人不認爲答案足夠有用;一個真正喜歡橙色顛倒三角形並希望看到更多的人? – Krease 2014-08-27 20:09:49

1

設置font-stylenormal迫使<em>總是是非ITAL或inherit從父繼承設置(demo):

<div class="normal"> 
    <h1><code>font-style:normal;</code> <small>- Always non-ital</small></h1> 
    <p>Should not be ital: <em>Foo</em></p> 
    <p class="ital">Should be ital: <em>Foo</em></p> 
</div> 
<div class="inherit"> 
    <h1><code>font-style:inherit;</code> <small>- Inherits from parent</small></h1> 
    <p>Should not be ital: <em>Foo</em></p> 
    <p class="ital">Should be ital: <em>Foo</em></p> 
</div> 
.normal em { 
    font-weight:bold; 
    font-style:normal; 
} 
.inherit em { 
    font-weight:bold; 
    font-style:inherit; 
} 
.ital { 
    font-style:italic; 
} 
3

您可以將以下內容添加到您的css

em { font-style: normal; font-weight: bold; } 

你也可以創建一個類來對特定EM標籤

CSS: .non-italic{ font-style: normal; font-weight: bold; } 
HTML: <em class="non-italic"></em> 

,或者你可以改變一個特定的EM標籤(不是好的做法)

<em style="font-style:normal; font-weight:bold;"></em> 
+0

我想提一下,CSS內聯樣式不是最佳實踐。您應該儘可能將內容和設計(可以放在頭標記中的小css片段除外)分開。所以給特定的em標籤一個類,並通過類選擇器引用它。 – 2014-08-27 20:15:44

+0

謝謝,你說得對,我會編輯我的答案來解決這個問題 – bobbyg603 2014-08-27 20:16:57

相關問題