-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
90 lines (80 loc) · 3.56 KB
/
index.html
File metadata and controls
90 lines (80 loc) · 3.56 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
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 name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>BMI</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
<style>
.navbarcontainer {
padding-left: 0px;
padding-right: 0px;
}
.box {
padding-left: 50px;
padding-right: 50px;
padding-top: 40px;
}
.btn-box {
padding-top: 71px;
}
</style>
<script>
$(function() {
$('#calc').click(function() {
let h = $('#height').val();
let w = $('#weight').val();
let bmi = w / (h * h);
$('#result').val(formatFloat(bmi, 3));
})
});
function formatFloat(num, pos) {
let size = Math.pow(10, pos);
return Math.round(num * size) / size;
}
</script>
</head>
<body>
<div class="container-fluid navbarcontainer">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse " id="navbarSupportedContent">
<ul class="navbar-nav mr-auto navbar-right">
<li class="nav-item">
<a class="nav-link" href="#">About</a>
</li>
</ul>
</div>
</nav>
<div class="row">
<div class="col-md-4 box">
<div class="form-group">
<label for="height">輸入身高(m)</label>
<input type="number" class="form-control" id="height" placeholder="身高">
</div>
</div>
<div class="col-md-4 box">
<div class="form-group">
<label for="weight">輸入體重(kg)</label>
<input type="number" class="form-control" id="weight" placeholder="體重">
</div>
</div>
<div class="col-md-1 btn-box">
<button class="btn" id="calc" type="button">送出</button>
</div>
<div class="col-md-3 box">
<div class="form-group">
<label for="result">您的 BMI</label>
<input type="number" class="form-control" id="result" readonly="true">
</div>
</div>
</div>
</body>
</html>