能用的东西
Morphing blob
流体变形色块
A soft gradient blob behind the content whose outline keeps morphing as it slowly turns.
Also searched as: 背景里一团慢慢变形的色块, 像液体一样扭动的圆形色块, 不规则的彩色圆团一直变形, 头像后面转着变形的渐变团
- Placement
- Background, Hero heading
- Mood
- Soft, Playful
- Trigger
- 一直循环
- Site types
- 个人网站, 作品集, 工具站
How it works & accessibility
An absolutely positioned gradient circle animates its eight border-radius values through four irregular shapes while the rotate property turns it once, ending on the same shape and angle so the loop never jumps; it sits behind the content in an isolated stacking context, ignores clicks, is hidden from screen readers and stays still with reduced motion.
Best for: Background, Hero heading (一直循环).
Reduced motion: 不动,留一个静止的色块
Mobile & touch: 和桌面一样;变形每一帧都要重画色块,一个页面放一两个就好
Key parameters
| Parameter | Key | Default | Range | Notes |
|---|---|---|---|---|
| 一圈多久 | duration | 16000ms | — | — |
Ready-to-paste AI prompt
Add “Morphing blob” to the background in my project: An absolutely positioned gradient circle animates its eight border-radius values through four irregular shapes while the rotate property turns it once, ending on the same shape and angle so the loop never jumps; it sits behind the content in an isolated stacking context, ignores clicks, is hidden from screen readers and stays still with reduced motion.
Parameters: duration: 16000ms.
Preserve existing content and layout. Respect prefers-reduced-motion by showing the final state. Content must remain visible if JavaScript fails or is disabled.
Reference: https://donglang.linter.top/effects/morphing-blob.md (canonical specification and reference code).Dependency-free reference code
CSS
/* 流体变形色块(Morphing blob)· 只用 CSS,不需要脚本。区块后面垫一团渐变色,边缘一直慢慢变形,同时缓缓转一圈。
同类效果见 Animation Handbook 的 morphing-blob(MIT);本站按通用做法自己实现,没有复制代码。
做法:色块的 border-radius 用八个值(四个角的横向、纵向半径)在四组不规则的形状之间过渡,同时用 rotate 属性转一圈;
首尾是同一个形状、同一个角度(0 和 360 度),接得上;用 rotate、translate 属性,不碰色块的 transform。
用法:区块加 class="mb",最前面放 <span class="mb-blob" aria-hidden="true"></span>,内容照常写在后面。
- 色块在内容下面(区块是一个独立的层叠上下文),不挡点击(pointer-events: none),区块把伸出去的部分裁掉(overflow: hidden)。
- 区块要有定位(relative、absolute、sticky 都行):默认的 position: relative 写在 :where() 里,网站自己写的定位优先;
但别在区块上写 position: static(色块会跑到更外层的定位祖先里)。
- 颜色:--mb-c1、--mb-c2(左上到右下的渐变);大小:--mb-size(色块的直径,按区块的宽算,默认 60%);
位置:--mb-x、--mb-y(色块的中心,默认在区块正中 50% 50%)。
- 一圈多久:--mb-duration(默认 16 秒);转得太快会晃眼。
- 变形每一帧都要重画色块(border-radius 交不给显卡),一个页面放一两个就好。
- 开启"减少动态"时:不动,留一个静止的色块。 */
/* 默认值和定位写在 :where() 里(不占优先级):网站自己在 .mb 上改颜色、大小、时长,或者区块自己写了定位,都用网站自己的 */
:where(.mb) {
--mb-duration: 16000ms;
--mb-c1: #ffc6d9;
--mb-c2: #c9d8ff;
--mb-size: 60%;
--mb-x: 50%;
--mb-y: 50%;
position: relative;
}
.mb {
overflow: hidden;
isolation: isolate;
}
.mb-blob {
position: absolute;
left: var(--mb-x);
top: var(--mb-y);
width: var(--mb-size);
aspect-ratio: 1;
translate: -50% -50%;
z-index: -1;
pointer-events: none;
background: linear-gradient(135deg, var(--mb-c1), var(--mb-c2));
border-radius: 42% 58% 63% 37% / 41% 44% 56% 59%;
animation: mb-morph var(--mb-duration) linear infinite;
}
@keyframes mb-morph {
0% { border-radius: 42% 58% 63% 37% / 41% 44% 56% 59%; rotate: 0deg; }
25% { border-radius: 63% 37% 41% 59% / 55% 62% 38% 45%; rotate: 90deg; }
50% { border-radius: 37% 63% 51% 49% / 37% 35% 65% 63%; rotate: 180deg; }
75% { border-radius: 55% 45% 32% 68% / 64% 46% 54% 36%; rotate: 270deg; }
100% { border-radius: 42% 58% 63% 37% / 41% 44% 56% 59%; rotate: 360deg; }
}
@media (prefers-reduced-motion: reduce) {
.mb-blob { animation: none; }
}HTML
<!-- 流体变形色块:区块加 class="mb",最前面放色块,内容照常写在后面 -->
<section class="mb">
<span class="mb-blob" aria-hidden="true"></span>
<h1>你好,我是北煜ii</h1>
<p>独立设计师,做网站和小工具</p>
</section>