给爱div+css+js的朋友共享,只要给你带来收获,也是我最大的快乐!!!此代码花了我好长时间才琢磨出来,不容易啊!!
<!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">
<HEAD><TITLE>position:fixed-JS模拟-6yang修改</TITLE>
<META http-equiv=Content-Type content="text/html; charset=GBK">
<STYLE type=text/css>BODY {
PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 30px; MARGIN: 0px; PADDING-TOP: 5px
}
.test {
BORDER-RIGHT: #ccc 1px solid; BORDER-TOP: #ccc 1px solid; MARGIN: 0px 5px 5px; BORDER-LEFT: #ccc 1px solid; LINE-HEIGHT: 100px; BORDER-BOTTOM: #ccc 1px solid; position:relative; height:100px;}
.test .aaa{ position:absolute; left:24px; top:30px; background:#ddd; width:254px; height:25px;}
.fixed {
RIGHT: 15px; BACKGROUND: #ccc; LEFT: 15px; BOTTOM: 0px; LINE-HEIGHT: 30px; POSITION: fixed; HEIGHT: 30px
}
#iefixed {
MARGIN: -1px 15px 0px; OVERFLOW: hidden; ZOOM: 1; HEIGHT: 1px
}
</STYLE>
<!--[if lt IE 7]>
<script type="text/javascript">
function _fixBackground(){
var body = document.body;
var BLANK_GIF;
if (body.currentStyle.backgroundAttachment != "fixed") {
if (body.currentStyle.backgroundImage == "none") {
body.runtimeStyle.backgroundImage = "url("+BLANK_GIF+")"; // dummy
body.runtimeStyle.backgroundAttachment = "fixed";
}
}
}
window.onload = function(){
_fixBackground();
}
</script>
<style type="text/css">
.fixed{
position: absolute;
bottom: auto;
clear: both;
width:expression(document.getElementById('iefixed').clientWidth);
left:expression(document.getElementById('iefixed').offsetLeft);
top:expression(eval(document.compatMode &&
document.compatMode=='CSS1Compat') ?
documentElement.scrollTop
+(documentElement.clientHeight-this.clientHeight)
: document.body.scrollTop
+(document.body.clientHeight-this.clientHeight));
}
</style>
<![endif]-->
</HEAD>
<BODY><!--[if lt IE 7]><div id="iefixed"></div><![endif]-->
<DIV class=test>6yang增加高度的</DIV>
<DIV class=test>6yang增加高度的<span class="aaa"></span></DIV>
<DIV class=test>6yang增加高度的</DIV>
<DIV class=test>6yang增加高度的</DIV>
<DIV class=test>6yang增加高度的</DIV>
<DIV class=test>6yang增加高度的</DIV>
<DIV class=test>6yang增加高度的</DIV>
<DIV class=test>6yang增加高度的</DIV>
<DIV class=test>6yang增加高度的</DIV>
<DIV class=test>6yang增加高度的</DIV>
<DIV class=test>6yang增加高度的</DIV>
<DIV class=test>6yang增加高度的</DIV>
<DIV class=test>6yang增加高度的</DIV>
<DIV class=fixed>这里是position:fixed部分.</DIV></BODY></HTML>
测试效果:http://www.6yang.net/other/fixed/index.html
loading