<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