gpt4 book ai didi

html - 如何在箭头周围绘制边框?

转载 作者:行者123 更新时间:2023-11-28 10:24:20 24 4
gpt4 key购买 nike

我想在整个箭头周围绘制边框,但问题出在右侧,因为它在正方形周围绘制。

原因是直 Angular 三 Angular 形是透明的,它看起来是这样的。否则,如果箭头颜色相同,则看不到它们。

任何想法如何做到这一点?

这里是 jsfiddle

HTML

.firstArrow {
position: relative;
background: red;
text-align: center;
margin-right: 10px;
margin-left: 0px;
height: 50px;
width: 330px;
float: left;
z-index: 3;
padding-left: 50px;
padding-top: 7px;
}

.firstArrow:before {
content: '';
position: absolute;
width: 20px;
height: 50%;
left: 100%;
top: 0;
background: linear-gradient(to right top,red 50%,transparent 50%);
}

.firstArrow:after {
content: '';
position: absolute;
width: 20px;
height: 50%;
left: 100%;
bottom: 0;
background: linear-gradient(to right bottom,red 50%,transparent 50%);
}

.secondArrow {
position: relative;
background: blue;
margin-right: 10px;
padding-left: 50px;
padding-top: 7px;
left: -20px;
float: left;
z-index: 2;
height: 50px;
width: 330px;

}
.secondArrow:before {
content: '';
position: absolute;
width: 20px;
height: 50%;
left: 100%;
text-align: center;
top: 0;
background: linear-gradient(to right top,blue 50%,transparent 50%);
}

.secondArrow:after {
content: '';
position: absolute;
width: 20px;
height: 50%;
left: 100%;
bottom: 0;
background: linear-gradient(to right bottom,blue 50%,transparent 50%);
}
.thirdArrow {
position: relative;
background: green;
text-align: center;
padding-top: 7px;
height: 50px;
width: 330px;
left: -40px;
float: left;
z-index: 1;
}

.thirdArrow:after {
content: '';
position: absolute;
width: 20px;
height: 50%;
left: 100%;
bottom: 0;
background: linear-gradient( to right bottom, green 50%,transparent 50%);
}
.thirdArrow:before {
content: '';
position: absolute;
width: 20px;
height: 50%;
left: 100%;
top: 0;
background: linear-gradient( to right top, green 50%, transparent 50%);
}
<div class="firstArrow"> 1 </div>
<div class="secondArrow"> 2 </div>
<div class="thirdArrow"> 3 </div>

最佳答案

您可以使用倾斜变换以不同方式处理形状:

.arrow {
position: relative;
text-align: center;
padding: 20px 0;
width: 100px;
float: left;
color: #fff;
z-index: 0;
}

.arrow:before,
.arrow:after {
content: "";
position: absolute;
box-sizing: border-box;
z-index: -1;
top: 0;
height: 50%;
left: -3px;
right: 0;
transform: skewX(45deg);
transform-origin: bottom;
background: var(--c, red);
border: 3px solid #000;
border-bottom: 0;
}

.arrow:after {
transform: scaleY(-1) skewX(45deg);
}

.arrow:first-child {
overflow: hidden;
border-left: 3px solid #000;
}
<div class="arrow"> 1 </div>
<div class="arrow" style="--c:blue;"> 2 </div>
<div class="arrow" style="--c:green;"> 3 </div>

关于html - 如何在箭头周围绘制边框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57567898/

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