• SVG/CSS路径动画


    <template>
        <div class="title">路径动画div>
        <div class="icon-box2">
            <div>CSS 路径动画div>
            
            <svg width="200" height="200">
                <path d="M10 80 C 40 10, 65 10, 95 80 S 150 150, 180 80" />
            svg>
            <div class="icon2">div>
        div>
        <div class="icon-box2">
            <div>SVG 路径动画div>
            <svg width="200" height="200">
                <path id="p1-line1" d="M10 80 C 40 10, 65 10, 95 80 S 150 150, 180 80" />
                <image x="-10px" y="-10px" xlink:href="@/assets/start.png" style="width: 20px; height:20px">
                    
                    <animateMotion dur="2.2s" rotate="auto" repeatCount="indefinite">
                        
                        <mpath xlink:href="#p1-line1">mpath>
                    animateMotion>
                image>
            svg>
        div>
        <div style="clear: both;">div>
        <br><br>
        <div class="title">闪光线沿着曲线运动div>
        <div class="icon-box2">
            <div>CSS 路径动画div>
            
            <svg width="200" height="200">
                <path d="M10 80 C 40 10, 65 10, 95 80 S 150 150, 180 80" />
            svg>
            <div class="icon3">div>
            <div class="icon3" style="animation-delay: 10ms;">div>
            <div class="icon3" style="animation-delay: 40ms; opacity: 0.9; transform: scale(0.9)">div>
            <div class="icon3" style="animation-delay: 60ms; opacity: 0.8; transform: scale(0.8)">div>
            <div class="icon3" style="animation-delay: 80ms; opacity: 0.7; transform: scale(0.7)">div>
            <div class="icon3" style="animation-delay: 100ms; opacity: 0.6; transform: scale(0.6)">div>
            <div class="icon3" style="animation-delay: 120ms; opacity: 0.5; transform: scale(0.5)">div>
            <div class="icon3" style="animation-delay: 140ms; opacity: 0.4; transform: scale(0.4)">div>
            <div class="icon3" style="animation-delay: 160ms; opacity: 0.3; transform: scale(0.3)">div>
        div>
    
    template>
    <script setup>
    
    script>
    <style lang="less" scoped>
    .title {
        padding: 5px 10px;
        margin-bottom: 10px;
        font-size: 16px;
        border-bottom: 1px solid #999;
    }
    
    svg {
        path {
            stroke: orange;
            fill: none;
            stroke-width: 2;
        }
    }
    
    .icon-box2 {
        position: relative;
        float: left;
    
        div {
            position: absolute;
        }
    
        .icon2 {
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background-color: red;
    
            /* 开启定位,配合偏移路径 */
            position: absolute;
            top: 0;
            left: 0;
            /* 元素运动路径 */
            offset-path: path("M10 80 C 40 10, 65 10, 95 80 S 150 150, 180 80");
            /* 初始偏移位置百分比  */
            offset-distance: 10%;
            animation: identifier2 2s linear infinite;
           
        }
    
        .icon3 {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            background-color: red;
            box-shadow: 0 0 10px red;
            /* 开启定位,配合偏移路径 */
            position: absolute;
            top: 0;
            left: 0;
            /* 元素运动路径 */
            offset-path: path("M10 80 C 40 10, 65 10, 95 80 S 150 150, 180 80");
            /* 初始偏移位置百分比  */
            offset-distance: -10%;
            animation: identifier2 1s linear infinite;
    
        }
    
        ;
    
    
    }
    
    @keyframes identifier2 {
        0% {
            offset-distance: 0%;
        }
    
        100% {
            offset-distance: 100%;
        }
    }
    style>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
  • 相关阅读:
    postgresql源码学习(23)—— 故障恢复④-事务日志的组装
    app小程序手机端Python爬虫实战10xpath定位方式
    抓住Linux黄金60秒
    2025武忠祥考研数学,视频百度网盘+基础全程课程PDF
    Adobe Premiere Pro 引入AI提升对话音质;Stable Diffusion:AI图像生成简介
    [附源码]计算机毕业设计springboot宠物领养与物品捐赠小程序
    每日三题 7.24
    神经网络滤镜安装教程图,ps神经网络滤镜安装包
    七月集训(20)BST
    zookeeper节点数据类型介绍及集群搭建
  • 原文地址:https://blog.csdn.net/qq_38946996/article/details/127987856