百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 技术文章 > 正文

用豆包生成的BMI计算器(豆包的热量是多少?)

zhezhongyun 2025-07-03 20:56 3 浏览

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>BMI 计算器</title>
    <style>
        :root {
            --body-bg-start: #e8eaf6;
            --body-bg-end: #d1c4e9;
            --card-bg: rgba(255, 255, 255, 0.9);
            --button-gradient-start: #7e57c2;
            --button-gradient-end: #9575cd;
            --button-hover-gradient-start: #673ab7;
            --button-hover-gradient-end: #8e67c7;
            --input-border: #bdbdbd;
            --input-focus-border: #7e57c2;
            --underweight-bg: #b3e5fc;
            --normal-bg: #c8e6c9;
            --overweight-bg: #ffe0b2;
            --obese-bg: #ffcdd2;
            --text-color: #212121;
            --shadow-color: rgba(0, 0, 0, 0.1);
        }

        body {
            font-family: 'Roboto', sans-serif;
            background: linear-gradient(to bottom, var(--body-bg-start), var(--body-bg-end));
            color: var(--text-color);
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            margin: 0;
        }

        .card {
            background-color: var(--card-bg);
            border-radius: 20px;
            box-shadow: 0 16px 32px var(--shadow-color);
            padding: 60px;
            width: 90%;
            max-width: 700px;
            box-sizing: border-box;
        }

        h1 {
            text-align: center;
            font-size: 32px;
            margin-bottom: 40px;
        }

        .input-group {
            margin-bottom: 30px;
        }

        label {
            display: block;
            margin-bottom: 12px;
            font-size: 20px;
            font-weight: 500;
        }

        input[type="number"] {
            width: 100%;
            padding: 18px;
            border: 1px solid var(--input-border);
            border-radius: 10px;
            transition: border-color 0.3s ease;
            font-size: 18px;
            box-sizing: border-box;
        }

        input[type="number"]:focus {
            border-color: var(--input-focus-border);
            outline: none;
        }

        button {
            width: 100%;
            padding: 18px;
            background: linear-gradient(to right, var(--button-gradient-start), var(--button-gradient-end));
            color: white;
            border: none;
            border-radius: 10px;
            box-shadow: 0 8px 16px var(--shadow-color);
            cursor: pointer;
            transition: background 0.3s ease;
            font-size: 20px;
            font-weight: 500;
        }

        button:hover {
            background: linear-gradient(to right, var(--button-hover-gradient-start), var(--button-hover-gradient-end));
        }

        #result {
            margin-top: 40px;
            padding: 30px;
            border-radius: 10px;
            text-align: center;
            display: none;
            font-size: 22px;
        }

        #result .bmi-value {
            font-size: 32px;
            font-weight: 700;
        }

        .danmaku {
            position: fixed;
            top: 0;
            right: 0;
            pointer-events: none;
            z-index: 999;
            white-space: nowrap;
            padding: 16px 32px;
            border-radius: 30px;
            color: white;
            background-color: hsl(calc(var(--random-hue, 0) * 360), 30%, 60%);
            animation: danmakuMove linear;
        }

        @keyframes danmakuMove {
            from {
                transform: translateX(100%);
            }
            to {
                transform: translateX(-100vw);
            }
        }
    </style>
</head>

<body>
    <div class="card">
        <h1>BMI 计算器</h1>
        <div class="input-group">
            <label for="height">你的身高(cm)</label>
            <input type="number" id="height" placeholder="请输入身高">
        </div>
        <div class="input-group">
            <label for="weight">你的体重(kg)</label>
            <input type="number" id="weight" placeholder="请输入体重">
        </div>
        <button onclick="calculateBMI()">计算 BMI</button>
        <div id="result"></div>
    </div>

    <script>
        function calculateBMI() {
            const height = parseFloat(document.getElementById('height').value);
            const weight = parseFloat(document.getElementById('weight').value);

            if (isNaN(height) || isNaN(weight) || height <= 0 || weight <= 0) {
                alert('请输入有效的身高和体重值。');
                return;
            }

            const bmi = (weight / ((height / 100) * (height / 100))).toFixed(2);
            let category = '';
            let message = '';
            let resultBg = '';

            if (bmi < 18.5) {
                category = '偏瘦';
                message = '风一吹,你怕是要像风筝一样飘走咯!';
                resultBg = getComputedStyle(document.documentElement).getPropertyValue('--underweight-bg');
            } else if (bmi >= 18.5 && bmi < 24) {
                category = '正常';
                message = '嘿,你这身材,老天爷赏饭吃的 “刚刚好” 呀!';
                resultBg = getComputedStyle(document.documentElement).getPropertyValue('--normal-bg');
            } else if (bmi >= 24 && bmi < 28) {
                category = '超重';
                message = '再胖点,你能去给熊猫当替身咯!';
                resultBg = getComputedStyle(document.documentElement).getPropertyValue('--overweight-bg');
            } else {
                category = '肥胖';
                message = '你不是胖,你是可爱到膨胀啦';
                resultBg = getComputedStyle(document.documentElement).getPropertyValue('--obese-bg');
            }

            const resultDiv = document.getElementById('result');
            resultDiv.innerHTML = `你的 BMI 值是:<span class="bmi-value">${bmi}</span>,体重分类:${category}`;
            resultDiv.style.display = 'block';
            resultDiv.style.backgroundColor = resultBg;

            generateDanmaku(message);
        }

        function generateDanmaku(message) {
            const numDanmaku = Math.floor(window.innerHeight / 50);
            for (let i = 0; i < numDanmaku; i++) {
                const danmaku = document.createElement('div');
                danmaku.classList.add('danmaku');
                danmaku.style.top = `${i * 50}px`;
                danmaku.style.setProperty('--random-hue', Math.random());
                danmaku.style.animationDuration = `${Math.random() * 8 + 4}s`;
                danmaku.textContent = message;
                document.body.appendChild(danmaku);

                danmaku.addEventListener('animationend', () => {
                    danmaku.remove();
                });
            }
        }
    </script>
</body>

</html>
    


相关推荐

用豆包生成的BMI计算器(豆包的热量是多少?)

<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8&#...

Android 开发中文引导-应用小部件

应用小部件是可以嵌入其它应用(例如主屏幕)并收到定期更新的微型应用视图。这些视图在用户界面中被叫做小部件,并可以用应用小部件提供者发布。可以容纳其他应用部件的应用组件叫做应用部件的宿主(1)。下面的截...

Qt推流(视频文件/视频流/摄像头/桌面转流媒体rtmp+hls+webrtc)

一、前言说明推流直播就是把采集阶段封包好的内容传输到服务器的过程。其实就是将现场的视频信号从手机端,电脑端,摄影机端打包传到服务器的过程。“推流”对网络要求比较高,如果网络不稳定,直播效果就会很差,观...

一看就会!谷歌广告转化跟踪详细设置指南来了

在出海推广业务中,投放广告最常见的目的是获取订单,但我们怎么知道有没有达成投放目的呢?谷歌转化跟踪技术就可以做到!熟悉谷歌的卖家朋友都知道,转化跟踪在最近几年变得越来越复杂了,虽然有很多选项可以自定义...

Android原生编解码接口MediaCodec详解

作者:躬行之MediaCodec是Android中的编解码器组件,用来访问底层提供的编解码器,通常与MediaExtractor、MediaSync、MediaMuxer、MediaCrypt...

手把手搭建RTSP流媒体服务器(rtsp 流媒体)

0.引言本文主要讲解如何搭建RTSP流媒体服务器的过程,使用开源项目ZLMediaKit。通过这个开源项目,推RTSP流到服务器,然后拉流端可以拉取RTSP、RTMP等流。ZLMediaKit码云链接...

MediaInfo 24.04.0 是一个关于多媒体文件的信息提供工具

MediaInfo24.04.0是一个关于多媒体文件的信息提供工具(仅当文件中包含信息时才提供):包括常规信息(标题、作者、导演、专辑、曲目编号、日期、时长等);视频信息(编解码器、画面比例、帧率...

rmvb格式视频怎么打开,rmvb转MP4认准这个方法

 一、rmvb是什么格式?  RMVB是一种视频文件格式,其中的VB指的是可变比特率。比起上一代的RM格式,RMVB  格式的画面比较清晰,因为它是降低了静态画面下的比特率。  二、制作rmvb  ①...

教你用Plex Media Server,把铁威马变成你的“私人好莱坞”!

TNAS(铁威马NAS)中可以安装多媒体服务器、影视、PlexMediaServer、EmbyServer作为个人媒体服务器使用。PlexMediaServer可以组织整理TNAS上的媒体...

你肯定用过!经典Windows软件被抛弃

Windows系统这些年持续更新的过程中,不断融入新的软件和功能的同时,一些经典的应用也渐渐成为了历史……Windows媒体播放器被抛弃Windows系统不断地推陈出新,一些老旧的组件也难免被抛弃,在...

博思得Q8标签打印全能手(博思得标签打印机安装教程)

2014-12-0905:35:00作者:宋达希【中关村在线办公打印频道原创】服装吊牌、洗涤标签、产品说明标签等都要用到标签打印机,这些标签涵盖多种尺寸的长度和宽度以及材质。另外作为一件商品或者产...

flv文件用什么播放器打开,这样做不踩雷!

FLV是FLASHVIDEO的简称,是随着FlashMX的推出发展而来的视频格式。它的出现有效地解决了视频文件导入Flash后,使导出的SWF文件体积庞大,不能在网络上很好的使用等问题。一、...

media player怎么转换格式?音频转换神器推荐!

Windowsmediaplayer怎么转换格式?WindowsMediaPlayer是微软公司出品的一款多媒体播放器,通常简称“WMP”。提供了编辑音频和视频文件的功能。用户可以使用该软件导...

视频参数检查工具更新:MediaInfo 23.10

MediaInfo提供有关视频或音频文件的技术和标签信息。信息示例包括编解码器、比特率、每秒帧数、宽度、高度、频道数、持续时间、标题、作者、字幕语言和章节名称。多种方式可以查看信息(文本、工作表、树和...

多媒体管理软件:JRiver Media Center 31.0.68 (64位)

JRiverMediaCenter64位是适用于大量库的完整媒体解决方案。它组织、播放和标记所有类型的媒体文件,并对Xbox、PS3、UPnP、DLNA和TiVo进行翻录、刻录。JRiverM...