CSS2.0position屬性_CSS教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
position屬性可將元素以static(靜態(tài))、relative(相對)、absolute(絕對)、fixed(固定)的方式來安置。
position屬性無繼續(xù)性。
Possible Values 可能用到的值
static
The element is placed in a normal position (according to the normal flow). With the value of "static" we do not use the "left" and "top" properties
元素以正常的形式形式來安置(以正常下垂的形式)。使用了static值我們就無法使用"left"以及"top"屬性
relative
Moves an element relative to its normal position, so "left:20" adds 20 pixels to the element's LEFT position
相對元素原本的位置來對它進行移動,因此"left:20"就會將元素的左定位增加20象素距。
relative是相對定位,它的參照點是該元素本來應該在要位置。比如說網(wǎng)頁上并排放A B C這三個元素,假如給B設的css style是position為relative,且給一個正的left值的話,那么B就可以顯示在C的右邊了。relative的這種定位比較怪,原來一直以為是相對別的什么東西定位的,昨天才知道是錯的。由于“該元素本來應該在要位置”在設計網(wǎng)頁的時侯不好琢磨,故relative方式是并不好用的方式,搞不好就會把網(wǎng)頁搞亂。
absolute
With a value of "absolute" the element can be placed anywhere on a page. The element's position is specified with the "left", "top", "right", and "bottom" properties
使用"absolute"值可以讓元素放到頁面的任何一個位置。元素的定位完全依靠"left","top","right"以及"bottom"的指定。
absolute是絕對定位,即當前元素的坐標是相對其上一級的左上角來表示的。這個上一級是整個page,或是嵌套在外層的一個DIV。而表格中的TD等元素不會成為上一層,也就是說想以當前單元格的左上角為參照,absolute地定位是不可以的。
position屬性無繼續(xù)性。
Possible Values 可能用到的值
static
The element is placed in a normal position (according to the normal flow). With the value of "static" we do not use the "left" and "top" properties
元素以正常的形式形式來安置(以正常下垂的形式)。使用了static值我們就無法使用"left"以及"top"屬性
relative
Moves an element relative to its normal position, so "left:20" adds 20 pixels to the element's LEFT position
相對元素原本的位置來對它進行移動,因此"left:20"就會將元素的左定位增加20象素距。
relative是相對定位,它的參照點是該元素本來應該在要位置。比如說網(wǎng)頁上并排放A B C這三個元素,假如給B設的css style是position為relative,且給一個正的left值的話,那么B就可以顯示在C的右邊了。relative的這種定位比較怪,原來一直以為是相對別的什么東西定位的,昨天才知道是錯的。由于“該元素本來應該在要位置”在設計網(wǎng)頁的時侯不好琢磨,故relative方式是并不好用的方式,搞不好就會把網(wǎng)頁搞亂。
absolute
With a value of "absolute" the element can be placed anywhere on a page. The element's position is specified with the "left", "top", "right", and "bottom" properties
使用"absolute"值可以讓元素放到頁面的任何一個位置。元素的定位完全依靠"left","top","right"以及"bottom"的指定。
absolute是絕對定位,即當前元素的坐標是相對其上一級的左上角來表示的。這個上一級是整個page,或是嵌套在外層的一個DIV。而表格中的TD等元素不會成為上一層,也就是說想以當前單元格的左上角為參照,absolute地定位是不可以的。
相關CSS教程:
- 相關鏈接:
- 教程說明:
CSS教程-CSS2.0position屬性
。