【发布时间】:2017-01-30 03:47:30
【问题描述】:
我需要制作一些看起来像 like this 的标签。起初,我尝试用普通的css 用边框技巧创建一个三角形,但制作灰色边框似乎是不可能的。我想用SVG 来做这件事,但我以前从来没有和那些人合作过,我有点卡住了。有人能指出我正确的方向吗? .谢谢
.c-tabs {
background: #fff;
border: 3px solid #e9e9e9;
}
.c-tabs:after,
.c-tabs:before {
display: table;
content: "";
}
.c-tabs:after {
clear: both;
}
.c-tabs__item {
float: left;
width: 25%;
padding: 22px 0;
color: #0b5d98;
font-size: 12px;
text-transform: uppercase;
font-family: nexaBlack, sans-serif;
text-align: center;
cursor: pointer;
position: relative;
}
.c-tabs__item svg:first-of-type {
position: absolute;
left: 0;
top: 0;
}
.c-tabs__item svg:last-of-type {
position: absolute;
right: -23px;
top: -2px;
bottom: -2px;
}
// .c-tabs__item :after {
// content: '';
// position: absolute;
// width: 20px;
// height: 100%;
// top: 0;
// right: 0;
// border-left: 30px solid transparent;
// border-top: 30px solid transparent;
// border-bottom: 30px solid transparent;
// background: #fff;
// z-index: 2;
//// box-shadow: 0 0 0 3px $light-base;
// }
// .c-tabs__item :before {
// content: '';
// position: absolute;
// height: 100%;
// width: 20px;
// height: 100%;
// top: 0;
// right: 0px;
// border-left: 33px solid #e9e9e9;
// border-top: 33px solid transparent;
// border-bottom: 33px solid transparent;
// z-index: 1;
// }
.c-tabs__item--active {
background: #03bfd7;
color: #fff;
box-shadow: inset 0 0 0 3px #03bfd7;
}
.c-tabs__item--active:after {
border-left: 30px solid #03bfd7;
}
<div class="c-tabs">
<div class="c-tabs__item c-tabs__item--active" data-tab="sumar">Pasul 1:sumar</div>
<div class="c-tabs__item" data-tab="account">Pasul 2: înregistrare
<svg width="100%" height="100%">
<line x1="0" y1="0" x2="100%" y2="0" stroke-width="3px" stroke="red"></line>
<line x1="0" y1="100%" x2="100%" y2="100%" stroke-width="3px" stroke="red"></line>
</svg>
<svg width="23px" height="100%">
<line x1="0" y1="0" x2="90%" y2="50%" stroke-width="2px" stroke="red"></line>
<line x1="0" y1="100%" x2="90%" y2="50%" stroke-width="2px" stroke="red"></line>
</svg>
</div>
<div class="c-tabs__item" data-tab="shipping">Pasul 3: livrare</div>
<div class="c-tabs__item" data-tab="review">Pasul 4: PLată</div>
</div>
【问题讨论】:
-
SVG 本质上只是另一种类型的图像,这不是您想要的——您需要 CSS 中的解决方案。此外,要求找到“关于 svg 的好课程”既是高度主观的,也是离题的。请查看documentation 以了解被视为“主题”的主题。
-
好的,我们可以忘记 svg 课程。为什么这里的 SVG 解决方案不好?