61,112
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.min.js"></script>
<style>
* {
margin: 0px;
padding: 0px;
}
#footer {
width: 100%;
height: 20px;
background: red;
bottom: 0px;
}
</style>
</head>
<body>
<div>
<div id="test">click here</div>
<p style="display:block;height:200px;background-color:yellow">asdf</p>
<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3
</div>
<div id="footer"></div>
<script>
function ct() {
return document.compatMode == "BackCompat" ? document.body.clientHeight : document.documentElement.clientHeight;
}
var f = document.getElementById('footer');
(window.onresize = function () {
f.style.position = document.body.scrollHeight > ct() ? '' : 'absolute';
})();
</script>
<script type="text/javascript">
$("#test").click(function () {
$("p").toggle();
});
</script>
</body>
</html>
<style>
*{margin:0px;padding:0px;}
#footer{width:100%;height:20px;background:red;bottom:0px;}
</style>
<div>
<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3<br>1<br>2<br>3
</div>
<div id="footer"></div>
<script>
function ct(){
return document.compatMode == "BackCompat"? document.body.clientHeight:document.documentElement.clientHeight;
}
var f=document.getElementById('footer');
(window.onresize=function(){
f.style.position=document.body.scrollHeight>ct()?'':'absolute';
})();
</script>