html做网页计算bmi,calculate-bmi.html

Heroism Gym Theme - Calculate BMI Page

BMI Calculator

What is BMI

Body mass index is a value derived from the mass and height of a person. The BMI is defined as the body mass divided by the

square of the body height, and is universally expressed in units of kg/m², resulting from mass in kilograms and height in metres

BMI Calculator Chart

BMIWeight Status
Below 18.5Underweight
18.5 to 24.9Healthy
25.0 to 29.9Overweight
30 and AboveObese

* BMR Metabolic Rate / BMI Body Mass Index

Calculate Your BMI

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dui. Aenean massa.

Gender:

Male

Female

She-Male

Select an activity factor:

Activity factor 1

Activity factor 2

Activity factor 3

Activity factor 4

Activity factor 5

Calculate

一键复制

编辑

Web IDE

原始数据

按行查看

历史

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当然,我可以帮你回答这个问题!以下是一个简单的BMI计算器的HTML、CSS和JavaScript代码: HTML代码: ``` <!DOCTYPE html> <html> <head> <title>BMI Calculator</title> <link rel="stylesheet" href="style.css"> </head> <body> <h1>BMI Calculator</h1> <div> <label for="weight">Weight (kg):</label> <input type="number" id="weight" required> </div> <div> <label for="height">Height (cm):</label> <input type="number" id="height" required> </div> <button onclick="calculateBMI()">Calculate</button> <div id="result"></div> <script src="script.js"></script> </body> </html> ``` CSS代码: ``` body { font-family: Arial, sans-serif; margin: 0; padding: 0; } h1 { text-align: center; } div { margin: 10px 0; } label { display: inline-block; width: 120px; } input { padding: 5px; } button { margin-top: 10px; padding: 10px; background-color: #008CBA; color: white; border: none; border-radius: 5px; font-size: 16px; cursor: pointer; } #result { margin-top: 20px; } ``` JavaScript代码: ``` function calculateBMI() { var weight = document.getElementById("weight").value; var height = document.getElementById("height").value / 100; var bmi = weight / (height * height); var category = ""; if (bmi < 18.5) { category = "Underweight"; } else if (bmi < 25) { category = "Normal weight"; } else if (bmi < 30) { category = "Overweight"; } else { category = "Obese"; } document.getElementById("result").innerHTML = "Your BMI is " + bmi.toFixed(1) + ", which means you are " + category + "."; } ``` 希望这个代码对您有所帮助!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值