首頁 > web前端 > css教學 > 主體

最窄770px最寬1024px的經典佈局研究_CSS/HTML

WBOY
發布: 2016-05-16 12:11:44
原創
2254 人瀏覽過

最典型實用的上中下,並且中間分三列的佈局,這個例子有2個特點:

1. 中間三列效果,可以任意實現單列背景色。
2. 整體最窄770px,最寬1024px,也就是說視窗小於770xp就出底部捲軸,如果大於1024px自動螢幕居中。

 

效果瀏覽:http://www.rexsong.com/blog/attachments/200512/29_154158_minmax_3col.htm

分析:

最外層的wrapper把所有內容都嵌套在裡邊,整體相對定位。 max min已經很好的控制了最窄最寬值,但對IE沒有作用。如果沒有其他佈局的穿插,這一層其實寫在body內就可以,少一層嵌套。
#wrapper{ width:auto; border:1px solid #000; min-width:770px; max-width:1024px; text-align:left; margin-left:auto; margin-right:relauative position:left; margin-left:auto; margin-right:relauative; ;}

wrapper 下級的 outer header footer

其中header絕對定位,footer 相對定位;outer分別對左右有130px的外邊距,這是相容非IE的關鍵。
#outer{ margin-left:130px; margin-right:130px; background:silver; border-left:1px solid #000; border-right:1px solid #000; color: #000;}
#🎜>#🎜> header{ position:absolute; top:0; left:0; width:100%; height:70px; line-height:70px; border-bottom:1px solid #000; overflow:hidden; background:#0ff; text-align :center; font-size:xx-large}
#footer { width:100%; clear:both; line-height:50px; border-top:1px solid #000; background:#ffc; color:#000 ; text-align:center; position:relative;}

outer 下級的 clearheader outerwrap right clearer

clearheader 用來填補header的空白,clearer 是常用的填充hack用法。
outerwrap 寬為什麼是99%,而不是100%?因為他的上層outer有邊框,100%寬再加2個邊框像素就會撐大,FF有明顯效果。
right 的處理很經典,IE下解析為定位,FF下則為浮動。負邊距的處理也剛好使用上outer留出的空白。
#clearheader{ height:72px;}
.outerwrap { float:left; width:99%;}
#right {
position:relative;
width:130prightx; float:130prightx; ; left:1px;
margin-right:-129px;
}
* html #right { margin-right:-130px; margin-left:-3px}
.clearer{ height:1px ; overflow:hidden; margin-top:-1px; clear:both;}

outerwrap 內的 centrecontent left clearer 就很簡單了,想法類似上邊說明。

來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!