1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > jquery实现div自适应浏览器高度

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

时间:2022-01-10 03:10:57

相关推荐

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

<!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="/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>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。