Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="lottie" id="lottie"</div>
              
            
!

CSS

              
                .lottie{
  width: 200px;
  height: 200px;
}
              
            
!

JS

              
                import lottie from "https://cdn.skypack.dev/lottie-web";
// 动画json数据
const animationJsonData = {
    "comps": [],
    "assets": [], // 静态资源
    "markers": [],
    "layers": [
        {
            "ddd": 0,
            "ind": 0,
            "ty": 4,
            "nm": "形状图层 1",
            // 动画信息
            "ks": {
                "o": {
                    "k": 100
                },
                "r": {
                    "k": 0
                },
                "p": {
                    "k": [
                        100,
                        100,
                        0
                    ]
                },
                "a": {
                    "k": [
                        0,
                        0,
                        0
                    ]
                },
                "s": {
                    "k": [
                        {
                            "i": {
                                "x": [
                                    0.833,
                                    0.833,
                                    0.833
                                ],
                                "y": [
                                    0.833,
                                    0.833,
                                    0.833
                                ]
                            },
                            "o": {
                                "x": [
                                    0.167,
                                    0.167,
                                    0.167
                                ],
                                "y": [
                                    0.167,
                                    0.167,
                                    0.167
                                ]
                            },
                            "n": [
                                "0p833_0p833_0p167_0p167",
                                "0p833_0p833_0p167_0p167",
                                "0p833_0p833_0p167_0p167"
                            ],
                            "t": 0,
                            "s": [ 100, 100, 100 ],
                            "e": [ 50, 50, 100 ]
                        },
                        {
                            "i": {
                                "x": [
                                    0.833,
                                    0.833,
                                    0.833
                                ],
                                "y": [
                                    0.833,
                                    0.833,
                                    0.833
                                ]
                            },
                            "o": {
                                "x": [
                                    0.167,
                                    0.167,
                                    0.167
                                ],
                                "y": [
                                    0.167,
                                    0.167,
                                    0.167
                                ]
                            },
                            "n": [
                                "0p833_0p833_0p167_0p167",
                                "0p833_0p833_0p167_0p167",
                                "0p833_0p833_0p167_0p167"
                            ],
                            "t": 90,
                            "s": [ 50, 50, 100 ],
                            "e": [ 100, 100, 100 ]
                        },
                        {
                            "t": 180
                        }
                    ]
                }
            },
            "ao": 0,
            // 图层信息
            "shapes": [
                {
                    "ty": "gr",
                    "it": [
                        {
                            "ty": "rc",
                            "d": 1,
                            "s": {
                                "k": [
                                    100,
                                    100
                                ]
                            },
                            "p": {
                                "k": [
                                    0,
                                    0
                                ]
                            },
                            "r": {
                                "k": 10
                            },
                            "nm": "矩形路径 1",
                            "mn": "ADBE Vector Shape - Rect"
                        },
                        {
                            "ty": "st",
                            "c": {
                                "k": [
                                    1,
                                    1,
                                    1,
                                    1
                                ]
                            },
                            "o": {
                                "k": 100
                            },
                            "w": {
                                "k": 0
                            },
                            "lc": 1,
                            "lj": 1,
                            "ml": 4,
                            "nm": "描边 1",
                            "mn": "ADBE Vector Graphic - Stroke"
                        },
                        {
                            "ty": "fl",
                            "c": {
                                "k": [
                                    0.26,
                                    0.47,
                                    0.67,
                                    1
                                ]
                            },
                            "o": {
                                "k": 100
                            },
                            "nm": "填充 1",
                            "mn": "ADBE Vector Graphic - Fill"
                        },
                        {
                            "ty": "tr",
                            "p": {
                                "k": [
                                    1.242,
                                    -4.326
                                ],
                                "ix": 2
                            },
                            "a": {
                                "k": [
                                    0,
                                    0
                                ],
                                "ix": 1
                            },
                            "s": {
                                "k": [
                                    100,
                                    100
                                ],
                                "ix": 3
                            },
                            "r": {
                                "k": 0,
                                "ix": 6
                            },
                            "o": {
                                "k": 100,
                                "ix": 7
                            },
                            "sk": {
                                "k": 0,
                                "ix": 4
                            },
                            "sa": {
                                "k": 0,
                                "ix": 5
                            },
                            "nm": "变换"
                        }
                    ],
                    "nm": "矩形 1",
                    "np": 3,
                    "mn": "ADBE Vector Group"
                }
            ],
            "ip": 0,
            "op": 180,
            "st": 0,
            "bm": 0,
            "sr": 1
        }
    ], // 图层信息
    "v": "4.5.4", // bodymovin版本
    "ddd": 0,
    "ip": 0,  // 开始帧
    "op": 180, // 结束帧
    "fr": 30, // 帧率
    "w": 200, // 宽
    "h": 200 // 高
};
// 初始化
const lot = lottie.loadAnimation({
   container: document.getElementById('lottie'), 
   renderer: 'svg',
   loop: true,
   autoplay: false,
   animationData: animationJsonData,
 });
// 开始播放动画
lot.play();
              
            
!
999px

Console