你能告诉我如何将内容宽度限制在屏幕边界吗?对于以下脚本,我总是得到比屏幕(允许的空间)宽度宽 2px 的宽度。
document.body.scrollWidth 始终比屏幕宽 2px
<html>
<head>
<style>
* {margin: 0; padding: 0}
</style>
<script type="text/javascript">
function test(){
alert(document.body.scrollWidth);
alert(document.getElementById("hrtest").scrollWidth);
alert(document.getElementById("divtest").scrollWidth);
alert(screen.width);
}
</script>
</head>
<body onLoad="test()">
<div id="divtest">
<hr size="2" width="100%" id="hrtest" />
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 如何编写将更改构造函数参数类型的绑定转换?