⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 11-6 绝对定位与相对定位.htm

📁 JAVASCRIPT完全自学手册,中源码的验证修订实例
💻 HTM
字号:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=GB2312" />
<title>11-6  绝对定位与相对定位</title>
<!-- 通用样式表 -->
<style>
* { font-size:12px; font-family:宋体, Arial; } /*规定了所有的字体样式*/
body { overflow:auto; border-style:none; margin:0px; padding:0px; }
.tools { position:absolute; top:180px; left:10px; }
#abs { position:absolute; left:10px; top:10px; width:150px; height:150px; background-color:buttonface; padding:10px; }
#rel { position:relative; left:170px; top:40px; width:150px; height:120px; background-color:buttonface; padding:10px; }
</style>
<script>
function logEvent(){
    $("ipt_x").value = event.x;
    $("ipt_y").value = event.y;
    $("ipt_x2").value = event.clientX;
    $("ipt_y2").value = event.clientY;
}

function $(str){ return(document.getElementById(str)); }

window.onload = function(){
    document.onmousemove = logEvent;
}
</script>
</head>
<body>
<div id="abs">绝对定位</div>
<div id="rel">相对定位</div>
<div class="tools">
    event.x <input id="ipt_x" size="15" >
    event.y <input id="ipt_y" size="15" >
    <br/>
    event.clientX <input id="ipt_x2" size="9" >
    event.clientY <input id="ipt_y2" size="9" >
</div>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -