0 Star 0 Fork 72

cui / 前端教学项目

forked from Albert / 前端教学项目 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
mobileDemo.html 1.50 KB
一键复制 编辑 原始数据 按行查看 历史
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0,user-scale=no">
<title>Document</title>
<style>
body{
color:white;
background-color:#222;
}
.spot{
position:absolute;
width:70px;
height:70px;
border-radius:35px;
box-shadow:0px 0px 40px #fff;
background-color:#fff;
opacity:.7;
}
</style>
</head>
<body>
随着手指移动的小圆球
<script>
let spot=null;
document.addEventListener("touchstart",(event)=>{
event.preventDefault();
if(spot){
return;
}
spot=document.createElement('div');
spot.classList.add('spot');
spot.style.top=event.touches[0].pageY-35+"px";
spot.style.left=event.touches[0].pageX-35+"px";
document.body.appendChild(spot);
},false);
document.addEventListener("touchmove",(event)=>{
event.preventDefault;
if(spot){
spot.style.top=event.touches[0].pageY-35+"px";
spot.style.left=event.touches[0].pageX-35+"px";
}
},false);
document.addEventListener("touchend",(event)=>{
event.preventDefault();
if(spot){
document.body.removeChild(spot);
spot=null;
}
},false);
</script>
</body>
</html>
HTML/CSS
1
https://gitee.com/cuizh/frontend_teaching_project.git
git@gitee.com:cuizh/frontend_teaching_project.git
cuizh
frontend_teaching_project
前端教学项目
master

搜索帮助