App.vue 波浪下划线
时间: 2025-03-27 16:10:20 浏览: 23
### 实现波浪下划线效果
为了在 `App.vue` 文件中实现波浪下划线效果,可以通过 CSS 和 Vue 的模板语法相结合来完成。具体来说,在 `<style>` 标签内定义所需的动画样式,并将其应用到目标 HTML 元素上。
#### 修改后的 App.vue 文件结构
```vue
<template>
<h1 class="wave-underline">Hello world!</h1>
</template>
<script setup></script>
<style lang="scss" scoped>
.wave-underline {
position: relative;
display: inline-block;
}
.wave-underline::after {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 2px;
background-color: transparent;
border-bottom: 2px solid blue;
transform-origin: center;
animation: wave 2s infinite linear;
}
@keyframes wave {
0%,
100% {
transform: translateX(0);
}
50% {
transform: translateX(-25%) skew(-25deg);
}
}
ul {
list-style: none;
}[^2]
a {
text-decoration: none;
color: black;
}
</style>
```
上述代码片段展示了如何创建一个带有波浪形下划线的效果。这里的关键在于使用伪元素 `::after` 来绘制线条并为其设置动画[@css-tricks]。同时保留了原有对全局样式的修改以保持一致性。
阅读全文
相关推荐



