html元素固定

來源:互聯網
上載者:User

標籤:back   blog   ott   logs   tab   position   width   div   idt   

1、position

值 描述
static        預設。位置設定為 static 的元素,它始終會處於頁面流給予的位置(static 元素會忽略任何 top、bottom、left 或 right 聲明)。
relative     位置被設定為 relative 的元素,可將其移至相對於其正常位置的地方,因此 "left:20" 會將元素移至元素正常位置左邊 20 個像素的位置。
absolute   位置設定為 absolute 的元素,可定位於相對於包含它的元素的指定座標。此元素的位置可通過 "left"、"top"、"right" 以及 "bottom" 屬性來規定。
fixed        位置被設定為 fixed 的元素,可定位於相對於瀏覽器視窗的指定座標。此元素的位置可通過 "left"、"top"、"right" 以及"bottom" 屬性來規定。不論視窗滾動與否,元素都會留在那個位置。工作於 IE7(strict 模式)。

2、z-index 屬性設定元素的堆疊順序。值越高越靠前面,僅能在定位元素上奏效(position:xx)

<html><head>    <title>Only fit FireFox! :(</title>    <!--Some thing about the fixed style!-->    <style type="text/css">        .fixed_div {            position: fixed;            left: 35%;            top: 30px;            width: 400px;            z-index: 1;        }    </style></head><body>    <div class="fixed_div" style="border:1px solid #200888;">content, I‘m content</div>    <div style="height:888px;background:yellow;"></div></body></html>

 

html元素固定

聯繫我們

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