JS代码如下:
/**
* 让div固定在页面底端
*
* @param
* @arrange (512.笔记) jb51.cc
**/
<script type="text/javascript"
src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("jquery","1.3.2");
google.setOnLoadCallback(function() {
var s = "";
for (var i = 0; i < 100; i++) {
s += "<div>這里是內容,很高</div>";
}
s += "<div>END</div>"
$("#container").html(s);
function my_resize() {
$("#container").height($("#right").height() - $("#copyright").outerHeight(true));
};
my_resize();
$(window).resize(function() {
my_resize();
})
});
</script>
CSS代码如下:
html,body {
height: 100%;
margin: 0;
overflow: hidden;
}
#right {
height: 100%;
position: relative;
background-color: Yellow;
}
#copyright {
height: 20px;
width: 100%;
background-color: Gray;
}
#container {
height: 2000px;
overflow-x: hidden;
overflow-y: auto;
}
HTML代码如下:
<div id="left"></div>
<div id="right">
<div id="container">
</div>
<div id="copyright">Copyright © 1999-2009,Michael Zhou,All Rights Reserved</div>
</div>
原文链接:https://www.f2er.com/js/527651.html