我已經制作了一個容器並將其設置爲中間寬度邊距:0 auto,但是我遇到了一個問題,就是我想使某些內容寬度適合窗口寬度爲100%寬度?如何使Div展開寬度爲100%
有什麼辦法可以做到嗎?
如果我使用填充:0 400px和margn-left:-200?
這是我的工作代碼。
CSS
html, body {width:100%; height:100%; background:lightblue}
* { margin:0; padding:0}
#container {
width:1024px;
min-height:100%;
background:red;
margin:0 auto;
position:relative;
}
header {
width:100%;
height:80px;
background:skyblue;
}
header ul {list-style-type:none; float:right}
header ul li {display:inline-block; padding: 10px; 20px;}
#content {
width:100%;
height:200px;
background:yellow;
padding:0 300px;
margin-left:-200px;
}
http://codepen.io/jaminpie/pen/CHrIf
Thansk用於幫助..
但仍需要保證金左:-200px吧?? – jamjamlong 2014-09-10 17:21:58
不,你不需要它,如果你的計劃是顯示完整的div它之前有 – 2014-09-10 17:23:03