-
Notifications
You must be signed in to change notification settings - Fork 0
/
triangle.html
90 lines (87 loc) · 2.36 KB
/
triangle.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<meta name="renderer" content="webkit">
<title>css3 实验</title>
<meta name="description" content="首页描述"/>
<meta name="keywords" content="首页关键词"/>
<meta name="author" content="Web Layout:amu"/>
<meta name="format-detection" content="telephone=no,date=no,address=no,email=no,url=no"/>
<link rel="stylesheet" href="./src/style/base.css?v=1">
<style>
#wrap{position: relative;margin:40px auto;width: 400px;height: 400px;border:1px solid #eee;border-radius: 50%;}
.ball{
position: absolute;
top:191px;
left:-9px;
width:6px;
height: 6px;
border:6px solid #f60;
border-radius:50%;
background:#f60;
transition: all .2s;
}
.seconds span{
position: absolute;
width: 2px;
height: 2px;
background: #ccc;
}
</style>
</head>
<body class="paper">
<div id="wrap">
<div class="ball"></div>
<p class="seconds"></p>
</div>
<div id="handleDir">
<button>up</button>
<button>down</button>
<button>left</button>
<button>right</button>
</div>
<script>
let dirEl = document.querySelector('#handleDir')
let dirObj = {
up:()=>{
},
right:()=>{
},
left:()=>{
},
down:()=>{
}
}
dirEl.onclick = (ev)=>{
if(ev.target.localName === "button"){
dirObj[btn.innerText]()
}
}
let ball = document.querySelector(".ball");
let seconds = document.querySelector(".seconds");
var timer ;
var x0=191,y0=191,r=200,degree=0,str = "";
timer = setInterval(function () {
degree++;
var hudu = 2*Math.PI/360*degree;
var x1 = x0 + Math.sin(hudu)*r;
var y1 = y0 - Math.cos(hudu)*r;
ball.style.left = x1 +"px";
ball.style.top = y1 + "px";
},1000)
function create() {
for(var times=0;times<60;times++){
var hudu = 2*Math.PI/360*6*times;
var x1 = x0 + Math.sin(hudu)*r;
var y1 = y0 - Math.cos(hudu)*r;
str +="<span style='left:"+x1+"px;top:"+y1+"px;'></span>";
}
seconds.innerHTML = str;
}
create()
</script>
</body>
</html>