标签:
<!DOCTYPE html>
<html>
<head>
<meta charset=UTF-8 />
<title>jquery实现div自适应浏览器高度(宽度)</title>
<meta name="keywords" content="html5" />
<meta name="description" content="html5 test" />
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
function autoHeight() {
var h = $(window).height();
var h_old = 300;
if (h > h_old) {
$(".left").css(‘height‘, h);
} else {
return false; } }
$(function() {
autoHeight();
$(window).resize(autoHeight); })
</script>
<style type="text/css">
html, body {
margin: 0;
height: 100%;
}
.left {
width: 100px;
background: #E8EFF6;
margin-left: 100px;
}
</style>
</head>
<body>
<div class="left"> das </div>
</body>
</html>
标签:
原文地址:http://www.cnblogs.com/sjzbattle/p/5443041.html