示例工程 33-transitions
33-transitions/demo-02-properties/style.css
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
:root {
--border: #e2e8f0;
--primary: #2563eb;
--muted: #64748b;
--ease: cubic-bezier(0.2, 0.8, 0.2, 1);
--shadow: 0 8px 24px rgb(15 23 42 / 12%);
}
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;
}
.card {
max-width: 380px;
margin-top: 16px;
overflow: hidden;
border: 1px solid var(--border);
border-radius: 12px;
background: #ffffff;
transition:
transform 200ms var(--ease),
box-shadow 200ms var(--ease),
border-color 200ms linear,
background-color 200ms linear;
}
.media {
height: 100px;
background: linear-gradient(135deg, #2563eb, #7c3aed);
}
.body {
padding: 16px;
}
.body h2 {
margin: 0;
font-size: 16px;
}
.body p {
margin: 4px 0 0;
color: var(--muted);
font-size: 13px;
}
@media (hover: hover) {
.card:hover {
transform: translateY(-3px);
border-color: #bfdbfe;
background: #f8fafc;
box-shadow: var(--shadow);
}
}
ul {
max-width: 520px;
margin-top: 18px;
padding-inline-start: 20px;
color: var(--muted);
font-size: 13px;
}
@media (prefers-reduced-motion: reduce) {
.card { transition: none; }
.card:hover { transform: none; }
}