2014-02-06 54 views
1

我對CSS/HTML比較新,我試圖在無序列表中更改兩個部分的字體。無序列表中的不同字體樣式

這是我的HTML列表

<ul id="factlist"> 
    <li>Name: Roger George Moore</li> 
    <li>Born: 14 October 1927</li> 
    <li>Birth Place: Stockwell, London</li> 
    <li>Famous For: Playing James Bond 1973-1985</li> 
</ul> 

和CSS

#factlist li { 
/*Factlist contentright on Homepage*/ 
list-style-image: url('../images/bullets.png'); 
color: #ffffff; 
font-family: "Trebuchet MS", Helvetica, sans-serif; 
font-weight: normal; 
font-size: 1.9em; 

}

我基本上想要列表出現在斜體 '標題',然後將答案正常。所以像這樣...

名稱:羅傑·摩爾

出生:14 ...

等。

非常感謝。

回答

0

可以使用<em>標籤(link

<ul id="factlist"> 
    <li><em>Name:</em> Roger George Moore</li> 
    <li><em>Born:</em> 14 October 1927</li> 
    <li><em>Birth Place:</em> Stockwell, London</li> 
    <li><em>Famous For:</em> Playing James Bond 1973-1985</li> 
</ul> 

或者如果你喜歡使用CSS使用<span>

<ul id="factlist"> 
    <li><span class="emphasize">Name:</span> Roger George Moore</li> 
    <li><span class="emphasize">Born:</span> 14 October 1927</li> 
    <li><span class="emphasize">Birth Place:</span> Stockwell, London</li> 
    <li><span class="emphasize">Famous For:</span> Playing James Bond 1973-1985</li> 
</ul> 

li.emphasize { 
    font-style: italic; 
} 
0

要使用CSS font-style做到這一點。 W3SchoolsJSFiddle

HTML

<ul id="factlist"> 
    <li><span>Name</span>: Roger George Moore</li> 
    <li><span>Born</span>: 14 October 1927</li> 
    <li><span>Birth Place</span>: Stockwell, London</li> 
    <li><span>Famous For</span>: Playing James Bond 1973-1985</li> 
</ul> 

CSS

#factlist li { 
    /*Factlist contentright on Homepage*/ 
    list-style-image: url('../images/bullets.png'); 
    color: #ffffff; 
    font-family: "Trebuchet MS", Helvetica, sans-serif; 
    font-weight: normal; 
    font-size: 1.9em; 
} 

#factlist li span { 
    font-style:italic; 
} 

或者您可以使用<em>W3SchoolsJSFiddle

<ul id="factlist"> 
    <li><em>Name:</em> Roger George Moore</li> 
    <li><em>Born:</em> 14 October 1927</li> 
    <li><em>Birth Place:</em> Stockwell, London</li> 
    <li><em>Famous For:</em> Playing James Bond 1973-1985</li> 
</ul> 
相關問題