首页 > Web开发 > 详细

jquery实现div自适应浏览器高度

时间:2016-04-28 17:02:51      阅读:265      评论:0      收藏:0      [点我收藏+]

<!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>

jquery实现div自适应浏览器高度

原文:http://www.cnblogs.com/sjzbattle/p/5443041.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!