| 무료 BMI 계산기 |
:root {
–bg: #f7f7fb;
–card: #ffffff;
–text: #1f2937;
–muted: #6b7280;
–line: #e5e7eb;
–primary: #2563eb;
–ok: #16a34a;
–warn: #f59e0b;
–bad: #dc2626;
–under: #0ea5e9;
–radius: 16px;
}
* { box-sizing: border-box; }
body {
margin: 0; padding: 24px; background: var(–bg);
color: var(–text); font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Noto Sans, “Apple SD Gothic Neo”, “Malgun Gothic”, sans-serif;
}
.wrap { max-width: 780px; margin: 0 auto; }
.card {
background: var(–card); border: 1px solid var(–line); border-radius: var(–radius);
box-shadow: 0 10px 30px rgba(0,0,0,.04);
}
header { padding: 20px 24px; border-bottom: 1px solid var(–line); }
header h1 { margin: 0; font-size: 22px; }
header p { margin: 6px 0 0; color: var(–muted); font-size: 14px; }
.content { display: grid; gap: 24px; padding: 20px; }
.grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .grid { grid-template-columns: 1.1fr .9fr; } }
.section { padding: 16px; border: 1px dashed var(–line); border-radius: 12px; background: #fcfcff; }
.row { display:flex; gap:12px; align-items:center; flex-wrap:wrap; }
.field { flex:1 1 180px; }
label { display:block; font-size: 13px; color: var(–muted); margin-bottom: 6px; }
input[type=”number”], input[type=”text”], select {
width: 100%; padding: 12px 12px; border: 1px solid var(–line); border-radius: 10px; outline: none;
background: #fff; color: var(–text); font-size: 16px;
}
input:focus, select:focus { border-color: var(–primary); box-shadow: 0 0 0 4px rgba(37,99,235,.08); }
.unit-toggle, .std-toggle { display:flex; gap:12px; }
.radio {
display:inline-flex; align-items:center; gap:8px; padding:8px 10px; border:1px solid var(–line); border-radius:999px;
background:#fff; cursor:pointer; user-select:none; font-size:14px;
}
.radio input { accent-color: var(–primary); }
.result {
padding: 16px; border-radius: 12px; background: #f3f4f6; border:1px solid var(–line);
}
.result h2 { margin: 0 0 8px; font-size: 18px; }
.badge { display:inline-block; padding:4px 10px; border-radius: 999px; font-size:12px; font-weight: 600; border:1px solid rgba(0,0,0,.06); }
.badge.ok { background:#ecfdf5; color:#065f46; border-color:#a7f3d0; }
.badge.warn { background:#fff7ed; color:#7c2d12; border-color:#fed7aa; }
.badge.bad { background:#fef2f2; color:#7f1d1d; border-color:#fecaca; }
.badge.under { background:#eff6ff; color:#1e3a8a; border-color:#bfdbfe; }
.bar { height: 10px; background: #e5e7eb; border-radius: 999px; overflow: hidden; margin-top: 8px; }
.bar > span { display:block; height: 100%; width:0%; background: var(–primary); transition: width .25s ease; }
.foot { padding: 12px 16px; color: var(–muted); font-size: 12px; border-top:1px solid var(–line); }
.actions { display:flex; gap:8px; flex-wrap: wrap; }
button {
padding: 10px 14px; border-radius: 10px; border:1px solid var(–line); background:#fff; cursor:pointer;
font-size:14px;
}
button.primary { background: var(–primary); color:#fff; border-color:var(–primary); }
.table { width:100%; border-collapse: collapse; font-size:14px; }
.table th, .table td { padding:10px; border-bottom:1px solid var(–line); text-align:left; }
.table th { color: var(–muted); font-weight:600; }
BMI 계산기
키와 몸무게를 입력하면 실시간으로 BMI와 체중 범주를 계산합니다. 기본 분류는 한국/아시아-태평양 기준입니다.
입력
결과
분류표
| 구간 | 한국/아시아-태평양 | WHO(국제) |
|---|---|---|
| 저체중 | < 18.5 | < 18.5 |
| 정상 | 18.5 – 22.9 | 18.5 – 24.9 |
| 과체중 | 23.0 – 24.9 | 25.0 – 29.9 |
| 비만 I | 25.0 – 29.9 | 30.0 – 34.9 |
| 비만 II | ≥ 30.0 | 35.0 – 39.9 |
| 비만 III | – | ≥ 40.0 |
const $ = (s) => document.querySelector(s);
const ui = {
unitRadios: document.querySelectorAll(‘input[name=”unit”]’),
stdRadios: document.querySelectorAll(‘input[name=”std”]’),
metric: {
h: $(‘#heightCm’),
w: $(‘#weightKg’),
},
imp: {
ft: $(‘#heightFt’),
inch: $(‘#heightIn’),
lb: $(‘#weightLb’),
},
metricFields: $(‘#metric-fields’),
imperialFields: $(‘#imperial-fields’),
bmiValue: $(‘#bmiValue’),
bmiBadge: $(‘#bmiBadge’),
bmiBar: $(‘#bmiBar’),
rangeText: $(‘#rangeText’),
resetBtn: $(‘#resetBtn’),
};
function getUnit() {
return […ui.unitRadios].find(r => r.checked).value; // ‘metric’ | ‘imperial’
}
function getStd() {
return […ui.stdRadios].find(r => r.checked).value; // ‘asia’ | ‘who’
}
function cmFromImperial(ft, inch) {
const totalIn = (Number(ft)||0) * 12 + (Number(inch)||0);
return totalIn * 2.54;
}
function kgFromLb(lb){ return (Number(lb)||0) * 0.45359237; }
function classify(bmi, std){
if(!isFinite(bmi) || bmi <= 0) return { label: '입력을 시작하세요', cls: '', seg: 0 };
if(std === 'asia'){
if(bmi < 18.5) return { label:'저체중', cls:'under', seg: 15 };
if(bmi < 23) return { label:'정상', cls:'ok', seg: 35 };
if(bmi < 25) return { label:'과체중', cls:'warn', seg: 55 };
if(bmi < 30) return { label:'비만 I', cls:'bad', seg: 80 };
return { label:'비만 II', cls:'bad', seg: 100 };
} else {
if(bmi < 18.5) return { label:'저체중', cls:'under', seg: 15 };
if(bmi < 25) return { label:'정상', cls:'ok', seg: 40 };
if(bmi < 30) return { label:'과체중', cls:'warn', seg: 70 };
if(bmi < 35) return { label:'비만 I', cls:'bad', seg: 85 };
if(bmi < 40) return { label:'비만 II', cls:'bad', seg: 95 };
return { label:'비만 III', cls:'bad', seg: 100 };
}
}
function normalRangeKg(heightCm, std){
const hM = heightCm / 100;
if(!isFinite(hM) || hM 0) ? (wKg/(hM*hM)) : NaN;
ui.bmiValue.textContent = isFinite(bmi) ? fmt(bmi,1) : ‘-‘;
const c = classify(bmi, std);
ui.bmiBadge.className = `badge ${c.cls}`;
ui.bmiBadge.textContent = c.label;
ui.bmiBar.style.width = `${c.seg}%`;
const range = normalRangeKg(hCm, std);
if(range){
if(unit === ‘metric’){
ui.rangeText.textContent = `정상 체중 범위: ${fmt(range.min)}-${fmt(range.max)} kg`;
} else {
const toLb = (kg) => kg / 0.45359237;
ui.rangeText.textContent = `정상 체중 범위: ${fmt(range.min)}-${fmt(range.max)} kg (≈ ${fmt(toLb(range.min))}-${fmt(toLb(range.max))} lb)`;
}
} else {
ui.rangeText.textContent = ‘정상 체중 범위: -‘;
}
}
// Event wiring
[…ui.unitRadios].forEach(r => r.addEventListener(‘change’, () => {
const useMetric = r.value === ‘metric’ && r.checked;
ui.metricFields.style.display = useMetric ? ” : ‘none’;
ui.imperialFields.style.display = useMetric ? ‘none’ : ”;
update();
}));
[…ui.stdRadios].forEach(r => r.addEventListener(‘change’, update));
ui.metric.h.addEventListener(‘input’, update);
ui.metric.w.addEventListener(‘input’, update);
ui.imp.ft.addEventListener(‘input’, update);
ui.imp.inch.addEventListener(‘input’, update);
ui.imp.lb.addEventListener(‘input’, update);
ui.resetBtn.addEventListener(‘click’, () => {
ui.metric.h.value = ”;
ui.metric.w.value = ”;
ui.imp.ft.value = ”;
ui.imp.inch.value = ”;
ui.imp.lb.value = ”;
ui.unitRadios[0].checked = true; // metric
ui.stdRadios[0].checked = true; // asia
ui.metricFields.style.display = ”;
ui.imperialFields.style.display = ‘none’;
update();
});
update();

Leave a Reply