示例工程 20-responsive-units
20-responsive-units/demo-02-percent-vw/style.css
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
body {
margin: 0;
padding: 32px;
background: #f8fafc;
color: #0f172a;
font-family: system-ui, sans-serif;
line-height: 1.7;
}
h1 {
margin: 0 0 8px;
font-size: 26px;
}
.stage {
width: 320px;
max-width: 100%;
margin-top: 16px;
padding: 10px;
overflow: hidden;
border: 1px dashed #cbd5e1;
border-radius: 8px;
background: #ffffff;
}
.bar {
display: flex;
align-items: center;
height: 32px;
padding-left: 8px;
color: #ffffff;
font-size: 11px;
font-family: ui-monospace, monospace;
}
.bar + .bar {
margin-top: 8px;
}
.percent {
width: 50%;
background: #2563eb;
}
.vw {
width: 50vw;
background: #7c3aed;
}
.hint {
max-width: 60ch;
color: #64748b;
font-size: 12px;
}