<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
div {
position: absolute;
z-index: 1;
width: 100%;
height: 100%;
text-align: center;
filter: alpha(opacity = 5);
background-color: gray;
}
</style>
<script type="text/javascript">
function aa() {
var myForm = document.getElementById('myForm');
alert(myForm.offsetLeft);
}
</script>
</head>
<body onload="aa();">
显示值。。
<br /> 显示值
<br /> 显示值
<br />
<div>adsfas</div>
<form action="?" id="myForm">
<input type="text" name="aa" /> <br /> <input type="text" /> <br />
<input type="text" /> <br /> <input type="text" /> <br /> <input
type="text" /> <br /> <input type="text" /> <br />
</form>
</body>
</html>
本文通过一个简单的HTML与JavaScript结合的例子展示了如何在网页中使用绝对定位来创建覆盖整个浏览器窗口的灰色背景层,并通过JavaScript获取表单的位置信息。
375

被折叠的 条评论
为什么被折叠?



