我正在尝试创建波浪形的顶部和底部边框,如此处的图像
我尝试使用以下代码重新创建相同的效果
.wave{
background: white;
height: 25px;
position: relative;
}
.wave::before, .wave::after{
border-bottom: 5px solid rgba(237, 30, 30, 1);
}
.wave::before{
content: "";
position: absolute;
left: 0;
right: 0;
bottom: 0;
height: 12px;
background-size: 20px 40px;
background-image:
radial-gradient(circle at 10px -15px, transparent 20px, rgba(237, 30, 30, 1) 21px);
}
.wave::after{
content: "";
position: absolute;
left: 0;
right: 0;
bottom: 0;
height: 18px;
background-size: 40px 40px;
background-image:
radial-gradient(circle at 10px 26px, rgba(237, 30, 30, 1) 20px, transparent 21px);
}
.wavebottom{
background: rgba(237, 30, 30, 1);
height: 25px;
position: relative;
}
.wavebottom::before, .wave::after{
border-bottom: 5px solid rgba(237, 30, 30, 1);
}
.wave::before{
content: "";
position: absolute;
left: 0;
right: 0;
bottom: 0;
height: 12px;
background-size: 20px 40px;
background-image:
radial-gradient(circle at 10px -15px, transparent 20px, white 21px);
}
.wavebottom::after{
content: "";
position: absolute;
left: 0;
right: 0;
bottom: 0;
height: 18px;
background-size: 40px 40px;
background-image:
radial-gradient(circle at 10px 26px, white 20px, transparent 21px);
}
我在3个div中有代码。.第一个div具有wave类
第二个div具有背景颜色和内容
第三个div具有wavebottom类
但是我得到的波像是这样的结果
我正在处理一个宽度为1920像素的页面,我不确定如何使它看起来像第一个图像一样
答案 0 :(得分:3)
尝试使用此:
.wave-top {
position: relative;
margin-top: 20px;
}
.wave-top::before,
.wave-top::after {
border-bottom: 5px solid rgba(237, 30, 30, 1);
}
.wave-top::before {
content: "";
position: absolute;
left: 0;
right: 0;
bottom: 0;
height: 10px;
background-size: 20px 40px;
background-image: radial-gradient(circle at 10px -15px, transparent 20px, rgba(237, 30, 30, 1) 21px);
}
.wave-top::after {
content: "";
position: absolute;
left: 0;
right: 0;
bottom: 0;
height: 15px;
background-size: 40px 40px;
background-image: radial-gradient(circle at 10px 26px, rgba(237, 30, 30, 1) 20px, transparent 21px);
}
.wave-mid {
background-color: rgba(237, 30, 30, 1);
height: 50px;
}
.wave-bottom {
position: relative;
}
.wave-bottom::before,
.wave-bottom::after {
border-top: 5px solid rgba(237, 30, 30, 1);
}
.wave-bottom::before {
content: "";
position: absolute;
left: 0;
right: 0;
bottom: 0;
height: 10px;
background-size: 20px 40px;
background-image: radial-gradient(circle at 10px -15px, transparent 20px, #fff 21px);
}
.wave-bottom::after {
content: "";
position: absolute;
left: 0;
right: 0;
bottom: 0;
height: 15px;
background-size: 40px 40px;
background-image: radial-gradient(circle at 10px 26px, #fff 20px, transparent 21px);
}
<div class='wave-top'></div>
<div class="wave-mid"></div>
<div class="wave-bottom"></div>
您可以根据需要增加中div的高度。在这里,我将其保存为50px