+
95
-

css如何实现网页滚动元素进入可视化区域动画入场?

css如何实现网页滚动元素进入可视化区域动画入场?

之前都是js实现,听说现在css新特性支持,想试一下。

网友回复

+
0
-

其实也就三行代码:

animation: appear linear; animation-timeline: view(); animation-range: entry 0% cover 40%;

完整代码如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Animate On Scroll</title>
    <style>
        body {
            min-height: 200vh; /* 为了创造滚动效果 */
            padding: 20px;
            font-family: Arial, sans-serif;
        }

        .block {
            width: 300px;
            height: 200px;
            margin: 10px;
   ...

点击查看剩余70%

我知道答案,我要回答