-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex.08.html
87 lines (73 loc) · 2.45 KB
/
ex.08.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ex8</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css"
integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous" />
<style>
.wrap {
width: 800px;
height: 400px;
background-color: #ccc;
position: relative;
margin: 0 auto;
}
.box {
width: 100px;
height: 100px;
background-color: lightpink;
position: absolute;
top: 0;
left: 0px;
}
</style>
</head>
<body>
<div class="wrap">
<div class="box"></div>
</div>
<div class="py-3 text-center">
<div class="py-1">
<button id="up" class="btn btn-info">
<i class="fas fa-caret-up"></i>
</button>
</div>
<div class="py-1">
<button id="left" class="btn btn-info mx-3">
<i class="fas fa-caret-left"></i>
</button>
<button id="right" class="btn btn-info mx-3">
<i class="fas fa-caret-right"></i>
</button>
</div>
<div class="py-1">
<button id="down" class="btn btn-info">
<i class="fas fa-caret-down"></i>
</button>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.js"
integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script>
<script>
console.log($('.wrap').width());
console.log($('.box').width());
$('#right').on('click', function () {
$('.box').css('left', '+=100');
})
$('#left').on('click', function () {
$('.box').css('left', '-=100');
})
$('#up').on('click', function () {
$('.box').css('top', '-=100');
})
$('#down').on('click', function () {
$('.box').css('top', '+=100');
})
</script>
</body>
</html>