在 CSS 中为顶部和底部边框创建波浪形边框
Create wavy borders in CSS for top and bottom borders
我正在尝试创建波浪形的顶部和底部边框,就像这里的图片一样
我尝试使用以下代码重新创建相同的效果
.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 有波 class
第二个div有背景颜色和内容
第三个div有波底class
但我得到的波浪结果看起来像那样
我正在处理宽度为 1920 像素的页面,我不确定如何才能使它看起来与第一张图片一样
试试这个:
.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>
您可以根据需要增加 middle-div 的高度。这里我留着了50px
我正在尝试创建波浪形的顶部和底部边框,就像这里的图片一样
我尝试使用以下代码重新创建相同的效果
.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 有波 class
第二个div有背景颜色和内容
第三个div有波底class
但我得到的波浪结果看起来像那样
我正在处理宽度为 1920 像素的页面,我不确定如何才能使它看起来与第一张图片一样
试试这个:
.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>
您可以根据需要增加 middle-div 的高度。这里我留着了50px