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

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/lbdreaming/article/details/19988439

<%@ 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>

展开阅读全文

没有更多推荐了,返回首页