2009-11-20 49 views
0

海伊傢伙,我使用這個技巧來獲得一個跨瀏覽器100%的高度DIV100%的div(與DIV的頂部10px的邊距)

/* commented backslash hack \*/ 
html, body{height:100%;} 
/* end hack */ 
html,body {margin:0;padding:0} 

#outer{min-height:100%;height:auto;background:#ffffcc} 
* html #outer{height:100%;}/* ie6 and under*/ 

編輯:但是在我的div我有一個1px的頂部邊框和10px頂部邊距。這個加法總計16px。

任何想法如何編輯這個CSS來說明16px?

+0

DUPE和解決方案:http://stackoverflow.com/questions/485827/css-100-height-with-padding-margin – dotty 2009-11-20 12:21:16

回答

0

將它嵌套在一個新的div中,該div將自動從它的父級接管寬度。

+0

寬度?你的意思是身高? – dotty 2009-11-20 12:12:41

+0

也是,但你必須給parentdiv一個額外的設置'overflow:auto',然後給嵌套的div一個類,其中設置'padding:15px;' – Ben 2009-11-20 12:16:51

相關問題