forked from WebCode-yt/BMI-CALCULATOR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
96 lines (95 loc) · 1.96 KB
/
index.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
91
92
93
94
95
96
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>BMI Calculator</title>
</head>
<style media="screen">
body{
margin: 0;
padding: 0;
text-align: center;
font-family: sans-serif;
background-image: linear-gradient(120deg,#ff6b6b, #5f27cd);
min-height: 100vh;
}
div{
width: 500px;
position: absolute;
top: 50%;
left: 50%;
background-color: #fff;
transform: translate(-50%, -50%);
padding: 20px;
border-radius: 10px;
box-shadow: 1px 1px 20px #ee5253;
}
h2{
font-size: 30px;
font-weight: 600;
}
.text{
text-align: left;
margin-left: 150px;
}
#w, #h{
color: #222f3e;
text-align: left;
font-size: 20px;
font-weight: 200;
outline: none;
border: none;
background: none;
border-bottom: 1px solid #341f97;
width: 200px;
}
#w:focus, #h:focus{
border-bottom: 2px solid #341f97;
width: 300px;
transition: 0.5s;
}
#result{
color: #341f97;
}
#btn{
font-family: inherit;
margin-top: 10px;
border: none;
color: #fff;
background-image: linear-gradient(120deg,#ff6b6b, #5f27cd);
width: 150px;
padding: 10px;
border-radius: 30px;
outline: none;
cursor: pointer;
}
#btn:hover{
box-shadow: 1px 1px 10px #341f97;
}
#info{
font-size: 12px;
font-family: inherit;
}
</style>
<script type="text/javascript">
function BMI() {
var h=document.getElementById('h').value;
var w=document.getElementById('w').value;
var bmi=w/(h/100*h/100);
var bmio=(bmi.toFixed(2));
document.getElementById("result").innerHTML="Your BMI is " + bmio;
}
</script>
<body>
<div>
<h2>BMI Calculator</h2>
<p class="text">Height</p>
<input type="text" id="h">
<p class="text">Weight</p>
<input type="text" id="w">
<p id="result"></p>
<button id="btn" onClick="BMI()">Calculate</button>
<p id="info">Please enter height [cm] and weight [kg]</p>
</div>
</body>
</html>