关于如何用 CSS 实现不同类型波浪线

1. 样式一

在这里插入图片描述

<div class="box">
	<div class="wave"></div>
</div>
.box {
	position: relative;
	width: 800px;
	height: 30px;
	margin: 100px auto;
	background-color: #0f0;
}
.wave {
	position: absolute;
	left: 0;
	top: -5px;
	width: 100%;
	height: 20px;
	background: radial-gradient(circle, #0f0 10px, #0f0, transparent 10px, transparent);
	background-repeat: repeat-x;
	background-size: 18px 20px;
}

2. 样式二

在这里插入图片描述

<div class="box">
	<div class="wave"></div>
</div>
.box {
	position: relative;
	width: 900px;
	height: 30px;
	margin: 100px auto;
	background-color: #0f0;
}
.wave {
	position: absolute;
	left: 0;
	top: -9px;
	width: 100%;
	height: 20px;
	background: radial-gradient(circle, #0f0 10px, #0f0, transparent 10px, transparent);
	background-repeat: repeat-x;
	background-size: 30px 20px;
}

3. 样式三

在这里插入图片描述

<div class="box">
	<div class="wave"></div>
</div>
.box {
	position: relative;
	width: 900px;
	height: 30px;
	margin: 100px auto;
	overflow: hidden;
}
.aux-line {
	position: absolute;
	left: 0;
	top: -20px;
	width: 100%;
	height: 40px;
	background: radial-gradient(circle, transparent 10px, transparent, #f00 10px, #f00);
	background-repeat: repeat-x;
	background-size: 30px 30px;
	background-position: 0 0;
}

4. 样式四

在这里插入图片描述

<div class="box">
	<div class="wave"></div>
	<div class="aux-line"></div>
</div>
.box {
	position: relative;
	width: 900px;
	height: 30px;
	margin: 100px auto;
	background-color: #0f0;
}
.wave {
	position: absolute;
	left: 0;
	top: -5px;
	width: 100%;
	height: 20px;
	background: radial-gradient(circle, #0f0 10px, #0f0, transparent 10px, transparent);
	background-repeat: repeat-x;
	background-size: 30px 20px;
}
.aux-line {
	position: absolute;
	left: 0;
	top: -18px;
	width: 100%;
	height: 20px;
	background: radial-gradient(circle, #fff 10px, #fff, transparent 10px, transparent);
	background-repeat: repeat-x;
	background-size: 30px 20px;
	background-position: 15px 0;
}

5. 样式五

在这里插入图片描述

<div class="box">
	<div class="wave"></div>
	<div class="aux-line"></div>
</div>
.box {
	position: relative;
	width: 900px;
	height: 30px;
	margin: 100px auto;
}
.wave {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 20px;
	background: linear-gradient(45deg, transparent 45%, #0f0 55%, transparent 55%);
	background-repeat: repeat-x;
	background-size: 39px 20px;
	background-position: 10px 0;
}
.aux-line {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 20px;
	background: linear-gradient(135deg, transparent 45%, #0f0 55%, transparent 55%);
	background-repeat: repeat-x;
	background-size: 39px 20px;
	background-position: 30px 0;
}

6. 样式六

在这里插入图片描述

<div class="test"></div>
<div class="test1"></div>
body {
	background: linear-gradient(90deg, #0ff, #ccc);
}
.test {
	width: 800px;
	height: 200px;
	background: radial-gradient(circle, transparent 30px, transparent, #0f0 30px, #0f0);
	background-size: 100px 100px;
	background-repeat: repeat-x;
}
.test1 {
	width: 800px;
	height: 200px;
	background: radial-gradient(circle, #0f0 30px, #0f0, transparent 30px, transparent);
	background-size: 100px 100px;
	background-repeat: repeat-x;
}

如有错误,欢迎指正,谢谢!
以上内容仅供参考,欢迎大家讨论。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值