日本免费全黄少妇一区二区三区-高清无码一区二区三区四区-欧美中文字幕日韩在线观看-国产福利诱惑在线网站-国产中文字幕一区在线-亚洲欧美精品日韩一区-久久国产精品国产精品国产-国产精久久久久久一区二区三区-欧美亚洲国产精品久久久久

固定窗口方法 IE6 position:fixed bug

然后,開始寫代碼,測(cè)試,最終,IE6下依然有問題 。position:fixed;沒有正常顯示 。

固定窗口方法 IE6 position:fixed bug



正確的代碼:預(yù)覽/Demo | ie6_position_fixed_bug.txt(源代碼)


!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"html xmlns="http://www.w3.org/1999/xhtml"headmeta http-equiv="Content-Type" content="text/html; charset=utf-8" /titleIE6 position:fixed bug/titlestyle* { padding:0; margin:0;}#rightform { text-align:center; padding:50px; font:14px/22px Georgia, "Times New Roman", Times, serif; height:1200px; background:#ffc;}#rightform h1 { font-family:arial; background:#e8edef; height:300px; line-height:300px; margin-bottom:200px;}#rightform p { line-height:1.5em; background:#ffdfff; padding:90px 0;}#rightform form { background-color:#ddd; padding:10px 20px; border:1px solid #aaa; position:fixed; right:30px; top:120px;}/style!--[if IE 6]style type="text/css" html{overflow:hidden;} body{height:100%;overflow:auto;} #rightform form{position:absolute;}/style![endif]--/headbodydiv id="rightform"h1a href="" title="IE6 position:fixed bug" rel="bookmark"IE6 position:fixed bug/a/h2pposition:fixed; vs position:absolute;support by a title="我們"我們/a from jb51.net/pform id="g_search" method="get" action="#"input id="g_s" name="g_s" type="text" value=""/input id="g_submit" name="g_submit" type="button" value="https://www.rkxy.com.cn/dnjc/search" //form/div/body/html
ffcod = delpost.runcode21 .value; ffcod = ffcod.replace(/
/g,’’); delpost.runcode21 .value = https://www.rkxy.com.cn/dnjc/ffcod; 提示:您可以先修改部分代碼再運(yùn)行
在別的文章中看到,可以用position:absolute;來解決IE6的問題,不過,添加position:absolute;之后,依然沒有成功 。當(dāng)然,最終,還是用position:absolute;來解決 。只是,不一定能成功 。因?yàn)?,有一句非常重要的話需要理?。
【固定窗口方法 IE6 position:fixed bug】fixed元素的絕對(duì)位置是相對(duì)于HTML元素來說,滾動(dòng)條是body元素的 。(via,剛才竟然沒找到來源,囧 。)
只有記住了這句話,才知為什么position:absolute;很多地方都給出了結(jié)果,但當(dāng)時(shí)并未能解決 。因?yàn)閔tml被我設(shè)置position:relative 。是上面這一句啟發(fā)了我,最終才能夠解決這個(gè)問題 。我們拉動(dòng)滾動(dòng)條的時(shí)候,內(nèi)容都會(huì)隨著窗口滾動(dòng);這時(shí)滾動(dòng)的是body 。如果讓絕對(duì)定位的父級(jí)元素定為body,剛我們需要固定的某個(gè)模塊將會(huì)固定在網(wǎng)頁的某個(gè)位置,而不是固定在窗口的某個(gè)位置(貌似在firefox中,html與body之間的介限并不明確?) 。

我們需要做的是,讓body保持其原有高度,讓html只有一個(gè)窗口那么高 。代碼我們可以這樣寫:

復(fù)制代碼代碼如下:
html{overflow:hidden;} // 重要!
body{height:100%;overflow:auto;}

這時(shí),html將只有一個(gè)窗口那么高,超過的,直接hide 。而body會(huì)隨高度自動(dòng)變化 。這時(shí),我們可以利用絕對(duì)定位來定位我們想要固定在窗口某個(gè)位置的模塊 。假設(shè)我們要固定的內(nèi)容在右上角,代碼可以這樣寫:

復(fù)制代碼代碼如下:
html{overflow:hidden;}
body{height:100%;overflow:auto;}
#rightform form{position:absolute;right:30px;top50px;}

這樣,窗口就固定在右上角了 。而其他瀏覽器,我們可以用position:fixed;來解決固定的問題 。其他瀏覽器完整的代碼如下:

復(fù)制代碼代碼如下:
#rightform {text-align:center;padding:50px;font:14px/22px Georgia, "Times New Roman", Times, serif;height:1200px;background:#ffc;}
#rightform h1 {font-family:arial;background:#e8edef;height:300px;line-height:300px;margin-bottom:200px;}
#rightform p {line-height:1.5em;background:#ffdfff;padding:90px 0;}
#rightform form {background-color:#ddd;padding:10px 20px;border:1px solid #aaa;position:fixed;right:30px;top:120px;}

推薦閱讀