-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
57 lines (50 loc) · 1.6 KB
/
Copy pathindex.html
File metadata and controls
57 lines (50 loc) · 1.6 KB
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
<!DOCTYPE html>
<html>
<head>
<title>ろーりんぐさんかく</title>
<meta charset="utf-8">
<script src="https://code.jquery.com/jquery-3.2.1.slim.js"
integrity="sha256-tA8y0XqiwnpwmOIl3SGAcFl2RvxHjA8qp0+1uCGmRmg="
crossorigin="anonymous"></script>
<style>
#triangle {
position: absolute;
width: 0;
height: 0;
border-style: solid;
border-width: 0 100px 173.2px 100px;
border-color: transparent transparent #ffcc00 transparent;
}
</style>
</head>
<body>
<h1>ローリング△さんかく</h1>
<div id="triangle"></div>
<script>
//三角形の回転
let triangle = $("#triangle")
let r = 0;
triangle.css("bottom", "50%")
//三角形の場所
let vecRight = true;
let xp = 0;
$(document).ready(function(){
setInterval(function(){
if(r++ > 360){
r = 0
}else{
triangle.css("transform", "rotate(" + r + "deg)")
}
moveTriangle()
},10)
})
function moveTriangle() {
if(vecRight) xp++
else xp--
if(xp > $(window).width()) vecRight = false
else if (xp < 0)vecRight = true
triangle.css("left", xp + "px")
}
</script>
</body>
</html>