<html><head>
<script src="js.js"></script>
<title></title>
<style>
#box
{
background:red;
width:100%;
height:100%;
}
</style>
</head>
<body>
<div id="box"></div>
<script>
var x=$(window).width();
var y=$(window).height();
var a=x/2;
var b=y/2;
$(document).ready(function(){$("#box").css(width,a)});
$(document).ready(function(){$("#box").css(height,b});
</script>
</body>
</html>
我希望 div 的宽度和高度在每个屏幕尺寸上有所不同,但这段代码不起作用。任何帮助将不胜感激。:)