絕對位置——absolution

來源:互聯網
上載者:User

標籤:屬性   col   span   文檔   預設   div   html   gre   --   

 <!--絕對位置:
            當position的屬性值設定為absolution時,則開啟了元素的絕對位置
      absolution的特性:
           1.開啟了絕對位置,會使元素脫離文檔
          2.但是開啟絕對位置,如果不設定位移量,則元素的位置不會發生變化
          3.絕對位置是相對於離他最近的開啟了定位的祖先元素進行定位的(一般情況,開啟了子項目的絕對位置都會同時開啟父元素的相對定位)
                 如果所有的祖先元素都沒有開啟定位,則會相對於瀏覽器視窗進行定位
          4.絕對位置會使一個元素提升一個層級
          5.絕對位置會改變元素的性質
                         (1) 內嵌元素會變成塊元素
                           (2)塊元素的寬度和高度預設都會被內容撐開
          -->

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>postion</title>
        <style>
            .box1{
                width: 200px;
                height: 200px;
                background: red;                
            }
            .box2{
                width: 200px;
                height: 200px;
                background: yellow;
                position:absolute;
                left:200px;
                top:0px;    
            }
            .box3{
                width: 400px;
                height: 400px;
                background: green;
                position: relative;
                /*開啟box4的相對定位*/                
            }
            .box4{
                width: 300px;
                height: 300px;
                background: papayawhip;    
            }
            .sp{
                width: 200px;
                height: 200px;
                background: cyan;
                position: absolute;
            }
        </style>
    </head>
    <body>
      
        <div class="box1"></div>
        <div class="box3"><div class="box4"><div class="box2"></div></div></div>
        
        <span class="sp">這是一個span</span>
    </body>
</html>

絕對位置——absolution

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.