示例工程 50-performance
50-performance/demo-01-compositor/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 4px; font-size: 26px; }
p { margin: 0 0 16px; color: #64748b; font-size: 14px; }
.track {
position: relative;
height: 56px;
margin-bottom: 10px;
overflow: hidden;
border: 1px solid #e2e8f0;
border-radius: 8px;
background: #ffffff;
}
.label {
position: absolute;
top: 4px;
left: 8px;
color: #64748b;
font-size: 10px;
font-family: ui-monospace, monospace;
}
.box {
position: absolute;
top: 14px;
left: 0;
width: 40px;
height: 30px;
border-radius: 6px;
}
.transform-box {
background: #2563eb;
animation: move-transform 1.8s ease-in-out infinite alternate;
will-change: transform;
}
.left-box {
background: #dc2626;
animation: move-left 1.8s ease-in-out infinite alternate;
}
@keyframes move-transform {
from { transform: translateX(8px); }
to { transform: translateX(200px); }
}
@keyframes move-left {
from { left: 8px; }
to { left: 200px; }
}
pre {
margin-top: 16px;
padding: 14px;
border: 1px solid #e2e8f0;
border-radius: 10px;
background: #ffffff;
overflow: auto;
font-size: 12px;
}
code { font-family: ui-monospace, monospace; }
@media (prefers-reduced-motion: reduce) {
.box { animation: none; }
}