gpt4 book ai didi

html - 在 CSS 中为顶部和底部边框创建波浪形边框

转载 作者:行者123 更新时间:2023-11-27 23:17:01 25 4
gpt4 key购买 nike

我正在尝试创建波浪形的顶部和底部边框,就像这里的图片一样

enter image description here

我尝试使用以下代码重新创建相同的效果

.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 类

但我得到的波浪结果看起来像那样

enter image description here

我正在处理一个宽度为 1920px 的页面,我不确定如何才能使它看起来像第一张图片一样

最佳答案

尝试使用这个:

.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>

您可以根据需要增加中间部分的高度。这里我保留了 50px

关于html - 在 CSS 中为顶部和底部边框创建波浪形边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58222962/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com