<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=9,IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="renderer" content="webkit">
<meta charset="utf-8">
<title>移动端的距离</title>
<style>
*{margin:0;padding:0;}
html{
width: 100%;
height: 100%;
}
body{
width: 1500px;
height: 1000px;
position: relative;
}
.title{
text-align: center;
}
.main{
margin-left: 200px;
margin-top: 100px;
width: 400px;
height: 200px;
border: 1px solid
display: flex;
justify-content: center;
align-items: center;
box-sizing: border-box;
/*position: relative;*/
}
.box{
width: 200px;
height: 100px;
border: 1px solid
display: flex;
justify-content: center;
align-items: center;
box-sizing: border-box;
}
</style>
</head>
<body>
<div class="main">
<button class="box" id="mBox">移动端</button>
</div>
<div class="title">(基于jQuery.min.js)测试 clientX, pageX, radiusX, screenX</div>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script>
// var myBox = document.getElementById('mBox');
// myBox.addEventListener('click', function(e){
// alert("ss");
// });
// $("body").on('click', '#mBox', function(event) {
// event.preventDefault();
// alert("22");
// });
// var myBox = $("#mBox");
// myBox.on('touchstart', function(e) {
// e.preventDefault();
// console.log(e);
// let t = e.originalEvent.touches[0];
// // client 相对于浏览器左上角的鼠标偏移量。会随着滚动条的变化而变化。
// // console.log("t.clientX: " + t.clientX + " ---------- t.clientY: " + t.clientY);
// // page 相对于整个document左上角的偏移量,不会随着滚动条的变化而改变。
// // console.log("t.pageX: " + t.pageX + " ---------- t.pageY: " + t.pageY);
// // 能够包围用户和触摸平面的接触面的最小椭圆的水平轴(X轴)半径
// // console.log("t.radiusX: " + t.radiusX + " ---------- t.radiusY: " + t.radiusY);
// // screen相对于电脑屏幕的距离。鼠标不动的情况下,点击两个不同区域,xy值不会变化。
// console.log("t.screenX: " + t.screenX + " ---------- t.screenY: " + t.screenY);
// });
</script>
</body>
</html>