標籤: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元素固定