2014-01-26 54 views
0

我想創建一個流體網格佈局內的div,它具有延伸整個頁面寬度的背景顏色,但仍然保留內容,如深藍色和淡藍色的部分https://unroll.me/流體網格佈局內的全寬div背景色

+0

這個問題太模糊了,連篇累牘的其他問題和基本的搜索結果被覆蓋。不過,你可能想從這裏開始http://coding.smashingmagazine.com/2011/01/12/guidelines-for-responsive-web-design/ – monners

回答

1

首先,你需要爲藍色背景創建一個div。然後,您將需要在藍色背景div內創建一個div來保存您的內容。

<div id="blueBackground"> 

    <div id="contentDiv"> 

     <!-- your content here --> 

    </div> 

</div> 

接下來,您將樣式div的使用CSS

#blueBackground { 
    background:#hexcolor; 
    width:100%; 
    padding: 40px 15px; /* first number sets vertical padding - second sets horizontal */ 
} 

#contentDiv { 
    width: 100%; 
} 
+0

這工作!我只在網格容器外面放置div「blueBackground」,它完全符合我的要求。我感謝您的幫助! – user3232801

1
#mydiv { 
    width: 100%; 
    background: blue; 
}