gpt4 book ai didi

html - 按钮的多边形边框/边框半径

转载 作者:行者123 更新时间:2023-12-04 11:52:20 26 4
gpt4 key购买 nike

我正在尝试制作如下图所示的多边形边框形状。
poygon border button background
我试过的代码如下。

@import url('https://fonts.googleapis.com/css2?family=Poppins&display=swap');

.p-button{
background: transparent;
text-decoration: none;
background: #5344c6;
color: white;
padding: 15px 50px;
border-radius: 27px;
text-transform: uppercase;
font-family: "Poppins";
letter-spacing: 0.5px;
}

body{
display: flex;
height: 100vh;
align-items: center;
justify-content: center;

}
<a class="p-button" href="">Explore The Tech</a>

最佳答案

使用剪辑路径:

@import url('https://fonts.googleapis.com/css2?family=Poppins&display=swap');

.p-button{
background: transparent;
text-decoration: none;
background: #5344c6;
color: white;
padding: 15px 50px;
text-transform: uppercase;
font-family: "Poppins";
font-size:40px;
--h:45px; /* this is half the height, adjust it based on your code */
clip-path:polygon(
0 50%,
calc(0.134*var(--h)) 25%, /* 0.134 = 1 - cos(30) */
calc( 0.5*var(--h)) 6.7%, /* 6.7% = 0.134/2 * 100% */
var(--h) 0,
calc(100% - var(--h)) 0,
calc(100% - 0.5*var(--h)) 6.7%,
calc(100% - 0.134*var(--h)) 25%,
100% 50%,
calc(100% - 0.134*var(--h)) 75%,
calc(100% - 0.5*var(--h)) 93.3%, /* 93.3% = 100% - 6.7% */
calc(100% - var(--h)) 100%,
var(--h) 100%,
calc( 0.5*var(--h)) 93.3%,
calc(0.134*var(--h)) 75%);
}

body{
display: flex;
height: 100vh;
align-items: center;
justify-content: center;

}
<a class="p-button" href="">Explore The Tech</a>

关于html - 按钮的多边形边框/边框半径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68507558/

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