2015-10-30 59 views
0

我正在製作一個HTML網站的索引頁面,我不知道爲什麼這個CSS不起作用。我的CSS代碼如下,之後我的HTML代碼:溢出:自動不移動邊緣

body { 
    background-image:url("background.png"); 
    font-family:sans-serif; 
} 

#content { 
    margin:0 auto; 
    overflow:auto; 
    background-color:white; 
    border-radius:10px; 
    width:60%; 
} 

.header { 
    margin:10px; 
} 

.body { 
    margin:10px; 
} 

.footer { 
    margin:10px; 
} 

HTML代碼:

<!DOCTYPE html> 
<html> 
<head> 
    <title>Welcome!</title> 
    <link rel="stylesheet" type="text/css" href="stylesheet.css"> 
</head> 
<body> 
    <div id="content"> 
     <div id="header"> 
      <p>This is the header!</p> 
     </div> 
     <div id="body"> 
      <p>This is the body!</p> 
     </div> 
     <div id="footer"> 
      <p>This is the footer!</p> 
     </div> 
    </div> 
</body> 
</html> 

那麼,是什麼最終發生的是overflow: auto不設置側邊,但它是成功設置頂部和底部邊距。提前致謝。

順便說一句,所有的圖像也在目錄中,他們工作正常。

回答

1

您正在使用class您的CSS中的選擇器和您的HTML中的id屬性。

將您的CSS更改爲#header#body#footer

或者,將您的HTML更改爲class="header",class="body"class="footer"

+0

而且工作完美。感謝一堆! –