示例工程 37-filters-blend-modes
37-filters-blend-modes/app/style.css
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
*,
*::before,
*::after {
box-sizing: border-box;
}
body,
h1,
h2,
h3,
p,
ul {
margin: 0;
padding: 0;
}
body {
background: var(--color-bg);
color: var(--color-text);
font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
line-height: 1.7;
}
.site-header {
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
gap: var(--space-3);
padding: var(--space-4) var(--space-6);
border-bottom: 1px solid var(--color-border);
background: var(--color-surface);
}
.brand {
font-size: var(--text-xs);
font-weight: 700;
letter-spacing: 0.14em;
}
.site-header nav {
display: flex;
flex-wrap: wrap;
gap: var(--space-4);
}
.site-header nav a {
color: var(--color-muted);
font-size: var(--text-sm);
text-decoration: none;
}
.site-header nav a:hover,
.site-header nav a:focus-visible {
color: var(--color-primary);
}
.page {
width: min(100% - 40px, 900px);
margin: 0 auto;
padding: 36px 0 64px;
}
.eyebrow {
color: var(--color-muted);
font-size: var(--text-xs);
letter-spacing: 0.18em;
}
h1 {
margin: var(--space-1) 0 var(--space-2);
font-size: clamp(1.75rem, 1.2rem + 2.4vw, 2.6rem);
line-height: 1.12;
}
.lead {
max-width: 48ch;
color: var(--color-muted);
font-size: var(--text-base);
}
.panel {
margin-top: var(--space-4);
padding: var(--space-6);
border: 1px solid var(--color-border);
border-radius: var(--radius-lg);
background: var(--color-surface);
}
h2 { font-size: var(--text-lg); }
h3 {
margin-top: var(--space-6);
font-size: var(--text-sm);
color: var(--color-muted);
}
.panel > p {
margin-top: var(--space-2);
color: var(--color-muted);
font-size: var(--text-sm);
}
.hint {
margin-top: var(--space-2);
color: var(--color-muted);
font-size: var(--text-xs);
}
/* 1. 滤镜 */
.filter-grid {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: var(--space-3);
margin-top: var(--space-3);
}
.filter-cell {
margin: 0;
padding: var(--space-2);
border: 1px solid var(--color-border);
border-radius: var(--radius-md);
background: var(--color-bg);
}
.art {
position: relative;
height: 100px;
overflow: hidden;
border-radius: var(--radius-sm);
background:
radial-gradient(circle at 74% 24%, #fbbf24 0 16%, transparent 17%),
radial-gradient(circle at 22% 78%, #22d3ee 0 12%, transparent 13%),
linear-gradient(135deg, #2563eb, #7c3aed 55%, #db2777);
}
.art::before {
content: "";
position: absolute;
left: 12%;
top: 58%;
width: 46%;
height: 10%;
border-radius: 999px;
background: rgb(255 255 255 / 85%);
}
.art::after {
content: "";
position: absolute;
left: 12%;
top: 30%;
width: 26%;
height: 14%;
border-radius: 6px;
background: rgb(255 255 255 / 55%);
}
.f-blur { filter: blur(2px); }
.f-bright { filter: brightness(1.4); }
.f-contrast { filter: contrast(1.6); }
.f-gray { filter: grayscale(1); }
.f-sepia { filter: sepia(0.9); }
.f-sat { filter: saturate(2); }
.f-hue { filter: hue-rotate(120deg); }
.f-shadow { filter: drop-shadow(0 8px 12px rgb(15 23 42 / 45%)); }
figcaption {
margin-top: var(--space-1);
color: var(--color-muted);
font-size: 10px;
font-family: ui-monospace, Menlo, monospace;
}
/* 2. backdrop-filter */
.scene {
position: relative;
display: grid;
place-items: center;
min-height: 280px;
margin-top: var(--space-3);
overflow: hidden;
border-radius: var(--radius-md);
background: linear-gradient(135deg, #2563eb, #7c3aed 50%, #db2777);
}
.orb {
position: absolute;
border-radius: 50%;
filter: blur(2px);
}
.orb-a {
top: -30px;
left: 8%;
width: 180px;
height: 180px;
background: rgb(34 211 238 / 70%);
}
.orb-b {
right: 6%;
bottom: -40px;
width: 220px;
height: 220px;
background: rgb(251 191 36 / 70%);
}
.glass {
position: relative;
width: min(80%, 340px);
padding: var(--space-4);
border: 1px solid rgb(255 255 255 / 45%);
border-radius: var(--radius-md);
background: rgb(255 255 255 / 40%);
backdrop-filter: blur(12px) saturate(1.3);
box-shadow: var(--shadow-md);
}
.glass-tag {
color: #1e3a8a;
font-size: 10px;
font-family: ui-monospace, Menlo, monospace;
letter-spacing: 0.14em;
}
.glass h3 {
margin-top: 2px;
color: #0f172a;
font-size: var(--text-lg);
}
.glass p:last-child {
margin-top: var(--space-1);
color: #1e293b;
font-size: var(--text-sm);
}
/* 3. 混合模式 */
.blend-scene {
position: relative;
height: 240px;
margin-top: var(--space-3);
overflow: hidden;
border-radius: var(--radius-md);
background: linear-gradient(135deg, #1d4ed8, #7c3aed 55%, #be185d);
}
.blend-circle {
position: absolute;
width: 120px;
height: 120px;
border-radius: 50%;
}
.b-multiply {
top: 24px;
left: 10%;
background: #fbbf24;
mix-blend-mode: multiply;
}
.b-screen {
top: 70px;
left: 36%;
background: #22d3ee;
mix-blend-mode: screen;
}
.b-difference {
top: 36px;
right: 10%;
background: #f472b6;
mix-blend-mode: difference;
}
.blend-label {
position: absolute;
left: 12px;
bottom: 10px;
color: #ffffff;
font-size: 10px;
font-family: ui-monospace, Menlo, monospace;
letter-spacing: 0.16em;
}
.bb {
height: 120px;
margin-top: var(--space-2);
border-radius: var(--radius-md);
background-image:
linear-gradient(135deg, #2563eb, #7c3aed),
radial-gradient(circle at 30% 30%, #fbbf24, transparent 60%);
background-blend-mode: overlay;
}
/* 4. 注意 */
.notes {
margin-top: var(--space-3);
padding-inline-start: 1.25rem;
color: var(--color-muted);
font-size: var(--text-sm);
}
.notes li {
padding: var(--space-1) 0;
}
.site-footer {
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
gap: var(--space-2);
padding: var(--space-4) var(--space-6) 36px;
color: var(--color-muted);
font-size: var(--text-xs);
}
@media (max-width: 720px) {
.filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
.site-header { padding: var(--space-3) 18px; }
.page {
width: min(100% - 28px, 900px);
padding: 24px 0 44px;
}
.panel { padding: var(--space-4); }
}