矢印全体の周りに境界線を描きたいのですが、問題は右側にあり、正方形の周りに描かれています。
その理由は、直角三角形が透明で、そのように見えるからです。それがないと、同じ色の矢印は表示されません。
それを行う方法はありますか?
これが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>
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加