對於非IE6可以這樣寫
#top{
position:fixed;
bottom:0;
right:20px;
}
但是IE6是不支持fixed定位的,需要另外重寫
#top{
position:fixed;
_position:absolute;
bottom:0;
right:20px;
_bottom:auto;
_top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));
}
使用hack使IE6實現該效果,但是還沒有完,這時,這個東東會閃爍,需要以下代碼
*html{
background-image:url(about:blank);
background-attachment:fixed;
}
如果使固定在IE6頂部,使用下面代碼
#top{
_position:absolute;
_bottom:auto;
_top:expression(eval(document.documentElement.scrollTop));
}
固定在底部使用下面代碼
#top{
_position:absolute;
_bottom:auto;
_top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));
}
IE6 這是個爺爺,早應該退伍了!