js设置div大小随窗口大小变化

<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ include file="/jsp/share/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<script src="../js/jquery.js" type="text/javascript"></script>
<script type="text/javascript">

$(function(){
var mydiv=$("#mydiv");
var mydiv_resize=function(){
$(mydiv).css("width",$(window).width());
$(mydiv).css("height",$(window).height());
};
mydiv_resize();
$(window).resize(function(){
mydiv_resize();
});
});
</script>
</head>
<body>
<div id="mydiv" style="border:5px solid red; overflow: auto;" ></div>
</body>
</html>

你可能感兴趣的:(div)