gpt4 book ai didi

CSS:按钮上的多个箭头

转载 作者:技术小花猫 更新时间:2023-10-29 11:16:23 25 4
gpt4 key购买 nike

我想制作一个右边有多个箭头的按钮,如下所示:

enter image description here

这就是我所做的:https://jsfiddle.net/aqjfLy7s/ .我无法弄清楚如何使第一个箭头与按钮边框齐平。所有后续箭头也必须遵循相同的模式。

.wrapper {
width: 50%;
border: 1px solid #ccc;
padding: 50px 0px;
margin: auto;
display: flex;
justify-content: center;
align-items: flex-end;
}

.w1 {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
margin-left: 30px;
}

.w2 {
display: flex;
justify-content: center;
align-items: center;
margin-left: 30px;
margin-right: 30px;
background-color: #ffcc00;
padding: 10px;
}

.btn {
color: #000;
border: 1px solid #000;
border-right: none;
padding: 0.5rem 1rem;
width: 80%;
}

span {
width: 1rem;
height: 1rem;
border: 0.25rem solid;
border-color: black transparent transparent black;
transform: rotate(135deg);
margin-left: -12px;
}
<div class="wrapper">
<div class="w1">
<a class="btn" href="#">Test</a>
<span></span>
<span></span>
<span></span>
<span></span>
</div>
<div class="w2">123</div>
</div>

最佳答案

这是另一个代码较少的想法,您可以简单地依赖伪元素和倾斜转换

.box {
display:inline-block;
padding:10px;
margin-right:60px;
border:1px solid;
border-right:none;
position:relative;
}
.box:before,
.box:after{
content:"";
position:absolute;
margin-left:-1px;
top:-1px;
left:100%;
bottom:50%;
width:30px;
background:linear-gradient(to right,#000 28%,transparent 29%) 1px 0/25% 100%;
transform:skewX(45deg);
transform-origin:top;
}
.box:after {
transform:skewX(-45deg);
transform-origin:bottom;
bottom:-1px;
top:50%;
}
<div class="box">
some text
</div>

<div class="box">
some long long text
</div>


<div class="box">
2 lines <br> text
</div>

CSS multipe arrows button

您可以轻松缩放到任意数量的边框

.box {
--b:4;
display:inline-block;
padding:10px;
margin:5px;
margin-right:calc(var(--b)*15px);
border:1px solid;
border-right:none;
position:relative;
}
.box:before,
.box:after{
content:"";
position:absolute;
margin-left:-1px;
top:-1px;
left:100%;
bottom:50%;
width:calc(var(--b)*7.5px);
background:linear-gradient(to right,#000 28%,transparent 29%) 1px 0/calc(100%/var(--b)) 100%;
transform:skewX(45deg);
transform-origin:top;
}
.box:after {
transform:skewX(-45deg);
transform-origin:bottom;
bottom:-1px;
top:50%;
}
<div class="box">
some text
</div>

<div class="box" style="--b:2">
some long long text
</div>


<div class="box" style="--b:10">
2 lines <br> text
</div>


<div class="box" style="--b:30">
some long long text
</div>

enter image description here

这是一个Codepen玩代码

关于CSS:按钮上的多个箭头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57823257/

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