2012-07-05 16 views
0

我想申請的背景圖片(相同)兩個div標籤:CSS不適用於第二項,這裏有什麼錯?

.abc { background: url('images/autogen.png') no-repeat 0px -133px; width: 256px; height: 256px; }; 

.def { background: url('images/autogen.png') no-repeat 0px -0px; width: 128px; height: 128px; }; 

HTML:

<html><head><meta charset="utf8"><link href='main.css' rel='stylesheet' type='text/css'' media='all' /></head><body> 
<div class="def">def</div> 
<div class="abc">abc</div></body></html> 

但是,只有一個得到了展示,如果我把.DEF定義一個前.abc,.def顯示,.abc沒有背景。

enter image description here

+5

刪除';'在css文件的行尾。 – MarcinJuraszek

+0

@MarcinJuraszek我認爲應該刪除這些類型的問題。這些是非常低水平的問題。說啥?看看ppl仍在回答。 – SVS

回答

1

在你的CSS不使用;

更換

.abc { 
background: url('images/autogen.png') no-repeat 0px -133px; 
width: 256px; 
height: 256px; 
}; 

.def { background: url('images/autogen.png') no-repeat 0px -0px; 
width: 128px; 
height: 128px; }; 

 .abc { background: url('images/autogen.png') no-repeat 0px -133px; 
width: 256px; 
height: 256px; } 

     .def { background: url('images/autogen.png') no-repeat 0px -0px; 
width: 128px; 
height: 128px; } 

更多信息http://htmlhelp.com/reference/css/structure.html

1

我推測不應該有';'花括號之後

.abc { background: url('images/autogen.png') no-repeat 0px -133px; width: 256px; height: 256px; } 

.def { background: url('images/autogen.png') no-repeat 0px -0px; width: 128px; height: 128px; }