示例工程 38-gradients-patterns
38-gradients-patterns/demo-02-patterns/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; }
.grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 14px;
max-width: 760px;
margin-top: 16px;
}
figure {
margin: 0;
padding: 8px;
border: 1px solid #e2e8f0;
border-radius: 10px;
background: #ffffff;
}
.p {
height: 120px;
border-radius: 8px;
}
figcaption {
margin-top: 6px;
color: #64748b;
font-size: 11px;
font-family: ui-monospace, monospace;
}
.stripes {
background: repeating-linear-gradient(45deg, #2563eb 0 10px, #dbeafe 10px 20px);
}
.checker {
background:
conic-gradient(#cbd5e1 25%, #ffffff 0 50%, #cbd5e1 0 75%, #ffffff 0)
0 0 / 32px 32px;
}
.dots {
background:
radial-gradient(#2563eb 2.5px, transparent 3px) 0 0 / 18px 18px,
#eff6ff;
}
.grid-lines {
background:
repeating-linear-gradient(0deg, #cbd5e1 0 1px, transparent 1px 20px),
repeating-linear-gradient(90deg, #cbd5e1 0 1px, transparent 1px 20px),
#f8fafc;
}
.hard {
background: linear-gradient(90deg, #2563eb 0 25%, #7c3aed 25% 50%, #db2777 50% 75%, #f59e0b 75% 100%);
}
.cone {
background: conic-gradient(#2563eb 0 30%, #7c3aed 0 65%, #db2777 0 100%);
border-radius: 50%;
width: 120px;
margin-inline: auto;
}
@media (max-width: 600px) {
.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}