先是一团模糊
慢慢变清楚
Blur in
模糊到清晰
Bring blurred content into sharp focus.
Also searched as: 先是一团模糊,慢慢变清楚, 从模糊变清楚, 虚化渐显, 朦胧到清晰
- Placement
- Hero heading, Image
- Mood
- Soft, Refined
- Trigger
- 进入屏幕
- Site types
- 作品集, 品牌官网, 博客
How it works & accessibility
Animate filter blur and opacity together, ending with crisp, fully visible content.
Best for: Hero heading, Image (进入屏幕).
Reduced motion: 不播放动画,直接显示清楚的最终状态
Mobile & touch: 和桌面一样;大面积模糊在低端手机上可能掉帧,大图可以把起始模糊调小
Key parameters
| Parameter | Key | Default | Range | Notes |
|---|---|---|---|---|
| 时长 | duration | 700ms | — | — |
| 起始模糊 | blur | 14px | — | — |
| 缓动 | easing | cubic-bezier(0.16, 1, 0.3, 1) | — | — |
Ready-to-paste AI prompt
Add “Blur in” to the hero heading in my project: Animate filter blur and opacity together, ending with crisp, fully visible content.
Parameters: duration: 700ms, blur: 14px, easing: cubic-bezier(0.16, 1, 0.3, 1).
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/blur-in.md (canonical specification and reference code).Dependency-free reference code
CSS
/* 模糊到清晰不需要额外的样式:元素默认就是清楚的,动画开始前那一瞬才由脚本变模糊 */JavaScript
// 模糊到清晰(Blur in)· 原生 JS,不依赖任何库。
// 改写自 StyleKit 的 blur-in(MIT License,Copyright (c) 2026 AnxForever):动作来自它,默认值调过(原版 500ms、10px)。
// el 从模糊、透明开始,回到清楚、不透明。返回一个清理函数:调用它会停掉动画,元素回到最终状态。
// 开启"减少动态"时不播放,直接显示;动画用 fill: 'backwards',脚本出错或没执行时内容照样可见。
// ignoreReducedMotion 只给"用户主动点播放"的演示用,网站自己的元素不要打开它。
export function blurIn(el, {
duration = 700,
blur = 14,
easing = 'cubic-bezier(0.16, 1, 0.3, 1)',
ignoreReducedMotion = false,
} = {}) {
if (!ignoreReducedMotion && matchMedia('(prefers-reduced-motion: reduce)').matches) return () => {};
const animation = el.animate(
[{ opacity: 0, filter: `blur(${blur}px)` }, { opacity: 1, filter: 'blur(0px)' }],
{ duration, easing, fill: 'backwards' },
);
return () => animation.cancel();
}
// 元素进入屏幕时播放一次。
// 离屏幕底边还有 40px 时就开始(碰到一点就算):动画的第一帧是藏起来的,等露出一截再开始,会先完整露一下、再消失、再进场;
// 按露出的比例算,比屏幕还高的元素可能永远够不到比例、一直不播。root: document 让提前量按元素所在页面自己的视口算,放在 iframe 里也管用
export function blurInOnEnter(el, options) {
const io = new IntersectionObserver(([entry]) => {
if (!entry.isIntersecting) return;
io.disconnect();
blurIn(el, options);
}, { root: document, threshold: 0, rootMargin: '0px 0px 40px 0px' });
io.observe(el);
return () => io.disconnect();
}HTML
<!-- 模糊到清晰:给要出现的元素调用一次,比如首屏的配图 -->
<img class="cover" id="cover" src="cover.jpg" alt="封面图">
<script type="module">
import { blurInOnEnter } from './blur-in.js';
blurInOnEnter(document.getElementById('cover'));
</script>