淺析postion的屬性中absolute和fixed的區(qū)別
當(dāng)前位置:點(diǎn)晴教程→知識(shí)管理交流
→『 技術(shù)文檔交流 』
[p]css樣式中的postion元素,它有四個(gè)不同的屬性,即static | absolute | fixed | relative。[/p]
static
:
默認(rèn)值。無(wú)特殊定位,對(duì)象遵循h(huán)tml定位規(guī)則
absolute
:
絕對(duì)的。將對(duì)象從文檔流中拖出,使用[url=http://bbon.iifree.net/wp-admin/c_left.html] left [/url],[url=http://bbon.iifree.net/wp-admin/c_right.html] right [/url],[url=http://bbon.iifree.net/wp-admin/c_top.html] top [/url],[url=http://bbon.iifree.net/wp-admin/c_bottom.html] bottom [/url]等屬性相對(duì)于其最接近的一個(gè)最有定位設(shè)置的父對(duì)象進(jìn)行絕對(duì)定位。如果不存在這樣的父對(duì)象,則依據(jù) body 對(duì)象。而其層疊通過(guò)[url=http://bbon.iifree.net/wp-admin/c_zindex.html] z-index [/url]屬性定義
fixed
:
固定的。對(duì)象定位遵從絕對(duì)(absolute)方式。但是要遵守一些規(guī)范
relative
:
對(duì)象不可層疊,但將依據(jù)[url=http://bbon.iifree.net/wp-admin/c_left.html] left [/url],[url=http://bbon.iifree.net/wp-admin/c_right.html] right [/url],[url=http://bbon.iifree.net/wp-admin/c_top.html] top [/url],[url=http://bbon.iifree.net/wp-admin/c_bottom.html] bottom [/url]等屬性在正常文檔流中偏移位置
[p]其中的 absolute和fixed很多人始終搞不明白區(qū)別到底多細(xì)微,其實(shí),在ie里面的效果確實(shí)沒(méi)什么區(qū)別,但在ff等飛ie內(nèi)核的瀏覽器中的效果就很不一樣了。[/p]
[p]把下面一段代碼復(fù)制,放到.html文件里在ff里就可以看出區(qū)別來(lái)了。[/p]
[p][br][br][br][br]
我在屏幕的位置不會(huì)改變 [br][br] [br][br][/p]
我會(huì)隨屏幕滾動(dòng) [br]該文章在 2010/4/27 3:06:02 編輯過(guò) |
關(guān)鍵字查詢
相關(guān)文章
正在查詢... |