vue实现底部波浪
实现底部波浪效果的方法
在Vue中实现底部波浪效果,可以通过CSS绘制波浪图形或使用SVG波浪路径。以下是两种常见实现方式:
使用CSS绘制波浪
通过CSS的border-radius和伪元素创建波浪形状:
<template>
<div class="wave-container">
<!-- 页面内容 -->
<div class="wave"></div>
</div>
</template>
<style>
.wave-container {
position: relative;
height: 100vh;
}
.wave {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 100px;
background: linear-gradient(to right, #4facfe 0%, #00f2fe 100%);
border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}
</style>
调整border-radius的百分比可改变波浪曲率,例如:

50% 50% 0 0 / 60% 60% 0 0更平缓70% 70% 0 0 / 30% 30% 0 0更陡峭
使用SVG波浪路径
通过SVG的path元素创建精确波浪图形:
<template>
<div class="wave-container">
<!-- 页面内容 -->
<svg class="wave" viewBox="0 0 1200 120" preserveAspectRatio="none">
<path d="M0,0V46.29c47.79,22.2,103.59,32.17,158,28,70.36-5.37,136.33-33.31,206.8-37.5C438.64,32.43,512.34,53.67,583,72.05c69.27,18,138.3,24.88,209.4,13.08,36.15-6,69.85-17.84,104.45-29.34C989.49,25,1113-14.29,1200,52.47V0Z" opacity=".25" fill="#4facfe"></path>
<path d="M0,0V15.81C13,36.92,27.64,56.86,47.69,72.05,99.41,111.27,165,111,224.58,91.58c31.15-10.15,60.09-26.07,89.67-39.8,40.92-19,84.73-46,130.83-49.67,36.26-2.85,70.9,9.42,98.6,31.56,31.77,25.39,62.32,62,103.63,73,40.44,10.79,81.35-6.69,119.13-24.28s75.16-39,116.92-43.05c59.73-5.85,113.28,22.88,168.9,38.84,30.2,8.66,59,6.17,87.09-7.5,22.43-10.89,48-26.93,60.65-49.24V0Z" opacity=".5" fill="#4facfe"></path>
<path d="M0,0V5.63C149.93,59,314.09,71.32,475.83,42.57c43-7.64,84.23-20.12,127.61-26.46,59-8.63,112.48,12.24,165.56,35.4C827.93,77.22,886,95.24,951.2,90c86.53-7,172.46-45.71,248.8-84.81V0Z" fill="#4facfe"></path>
</svg>
</div>
</template>
<style>
.wave-container {
position: relative;
height: 100vh;
}
.wave {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 100px;
}
</style>
动态波浪动画
添加CSS动画让波浪产生流动效果:

.wave {
animation: wave 3s linear infinite;
}
@keyframes wave {
0% { transform: translateX(0); }
100% { transform: translateX(-50%); }
}
对于SVG方案,可修改path的d属性值实现更复杂的波浪运动。
响应式调整
通过媒体查询适应不同屏幕尺寸:
@media (max-width: 768px) {
.wave {
height: 50px;
}
}
第三方库方案
使用专为Vue设计的波浪组件库如vue-waves:
- 安装:
npm install vue-waves - 使用:
<template> <vue-waves :color="'#4facfe'" :height="100"/> </template>
这种方式可快速实现复杂波浪效果,支持自定义参数。






