为什么不设置文档的宽度。 我希望左边的div为100px,而右边的div为documentwidth - 100px 谢谢你的时间!
<html>
<head>
<link rel="stylesheet" type="text/css" href="stack.css">
<script language="javascript" type="text/javascript" src="jquery-1.8.3.js"></script>
</head>
<body>
</script>
<button></button>
<div id="parent">
<div id="left"></div>
<div id="right"></div>
</div>
<script language="javascript" type="text/javascript" src="jquery-1.8.3.js">
$(document).ready(function() {
var $doc_width = $(document).width();
var $rightwidth = $doc_width - 100;
$("#right").width($rightwidth);
});
});
</body>
</html>
答案 0 :(得分:2)
尝试此修改:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="stack.css">
<script src="jquery-1.8.3.js"></script>
</head>
<body>
<button></button>
<div id="parent">
<div id="left"></div>
<div id="right"></div>
</div>
<script>
$(document).ready(function() {
var $doc_width = $(document).width();
var $rightwidth = $doc_width - 100;
$("#right").width($rightwidth);
});
</script>
</body>
</html>