2015-10-26 31 views
-2

我試圖更改列表中項目的背景顏色,而未選擇整個列表。我希望第一個列表中的項目背景是綠色的,第二個列表是青色的,但是沒有項目符號將自己指向綠色背景?更改HTML5/CSS中特定列表項的顏色

我的代碼如下:

<!DOCTYPE html> 
<html> 
<head> 
    <title>CSS Exercises 1</title> 
    <link rel="stylesheet" type="text/css" href="exercise1.css"> 
</head> 
<body> 
    <ul id="unordered_list"> 
     <li>This is an unordered list.</li> 
     <li>All items in this list should have a yellow background.</li> 
     <li>Just the items though - not the whole list!</li> 
    </ul> 

    <ol id="ordered_list"> 
     <li>This is an ordered list.</li> 
     <li>All items in this list should have a teal background.</li> 
     <li>Just the items thought - not the whole list!</li> 
    </ol> 

</body> 
</html> 

我的CSS:

#unordered_list { 
background-color: yellow; 
} 

#ordered_list li{ 
background-color: rgb(2, 132, 130); 
} 

謝謝!

+0

我不太明白你想要什麼...我看到你在那裏取得了一些... –

+0

加上'li'以'#unordered_list'像下面的'#ordered_list的一個li' – cocoa

+0

http://jsfiddle.net/h3p7v70j/ – deebs

回答