需要帮助用svg创建标签

时间:2017-01-29 19:19:06

标签: html css svg

我需要制作一些看起来like this的标签。起初我尝试用普通name创建一个带有边框技巧的三角形,但似乎不可能制作灰色边框。我想用css来做这件事,但我从来没有和那些人合作过,而且我有点卡住了。有人能指出我正确的方向吗? .Thanks

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;
}

1 个答案:

答案 0 :(得分:0)

如果您的目标是使用SVG而不是CSS制作这些三角形,您可以在Sketch或Illustrator中制作它们,然后将它们导出为SVG,然后将其导入到项目中。

Here是有关如何使用Adobe Illustrator进行操作的指南。

here是关于如何使用Sketch进行操作的指南。

您的工作流程将类似于:

步骤1 - 在Illustrator或Sketch中制作形状

第2步 - 将形状导出为SVG代码

步骤3 - 将SVG代码直接导入项目

相关问题