CSS中關於absoulte屬性的具體分析

來源:互聯網
上載者:User

特性:

absoulte float 具有相同的特性:包裹性,與破壞性
absoulte float 可以交替使用
不受 relative 限制的 absoulte 定位,行為表現上可以不使用 left/right/top/button/auto 等屬性

行為表現

脫離文檔流
去浮動( float absoulte 元素不能同時出現)
位置跟隨(還在原來的位置)
問題: IE7使用 absoulte 的元素永遠是 inline-block 元素
解決: 外層套一層無設定屬性的標籤

可以配合margin 精確定位

支援負值定位
相容性強 IE6
自適應強,維護性好,具有健壯性

動畫盡量作用與絕對位置元素上,多個 absoulte 元素會重疊,後者居上

z-index 無依賴

如只有一個 absoulte 元素,不需要設定
如兩個 absoulte 元素,控制DOM流的順序,也可不需要
多個定位交錯, z-index: 1 控制
非彈框類的 absoulte 元素, z-index <= 2 若冗餘,需最佳化

left/right/top/bottom與width/height可相互替代


left:0;right:0;    等於 width:100%;top:0;bottom:0;    等於 height:100%;以上IE7+支援具有相互合作性:left:0;right:0;width:50%;margin:auto;可置中

absoulte整體布局


<header></header><article>   <aside></aside>   <main></main></article><footer></footer>


1 header,footer{ positon:absoulte; left:0; right:0; }2 header{ height: 50px; top: 0; }3 footer{ height: 20px; bottom: 0; }4 aside{ position: absoulte width: 200px; top: 0; bottom: 0; left:0; }5 main{ position: absoulte; top: 50px; bottom: 50px; right: 0; left: 200px; overflow: auto;}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.