2013-07-19 74 views
0

我創建了一個名爲WebSpace的網站,我希望頭部背景色可以從頭到尾拉伸。目前,它看起來像這樣:使用CSS創建全寬背景色

enter image description here

我想獲得的頂部去掉多餘的空格,左,右,用乾淨的解決方案,如果可能的。

下面是HTML:

<!DOCTYPE html> 
<html> 
    <head> 
    <link rel="stylesheet" href="/assets/style.css"/> 
    <link rel="stylesheet" href="/assets/layout.css"/> 
    <title>WebSpace</title> 
    </head> 
    <body> 
    <div class="row title"> 
     <span class="title">WebSpace</span> 
    </div> 
    </body> 
</html> 

style.css文件:

@import url(http://fonts.googleapis.com/css?family=Roboto:400,700,100&subset=cyrillic,cyrillic-ext,latin-ext,latin); 
body { 
    font-family: 'Roboto', sans-serif; 
} 
span.title { 
    font-weight: 100; 
    font-size: 66px; 
    width: 100%; 
    float: left; 
} 

而且我layout.css中的文件:

body { overflow-x:hidden; !important} 
html { width: 100%; } 
div.row { width: 100%; } 
div.span10 { width: 100%; } 
div.span9 { width: 90%; } 
div.span8 { width: 80%; } 
div.span7 { width: 70%; } 
div.span6 { width: 60%; } 
div.span5 { width: 50%; } 
div.span4 { width: 40%; } 
div.span3 { width: 30%; } 
div.span2 { width: 20%; } 
div.span1 { width: 10%; } 

/*Row Styles*/ 
div.title { 
    background-color: #F7D023; 
    height: 100px; 
    color: white; 
    position: absolute: 
    left: 0; 
    right: 0; 
    overflow-x:hidden; !important 
} 
+1

你試過了:body {margin:0;}? –

回答

5

瀏覽器使用的是不同的默認樣式表。認沽:

html, body { 
    padding: 0; 
    margin: 0; 
} 

JSFiddle

或者更好,使用CSS reset

+0

或「最佳」,使用[CSS規範](http://necolas.github.io/normalize.css/)。 – AlicanC