CSS Ribbon - 控制边的宽度

时间:2014-09-23 17:02:21

标签: css shapes css-shapes

.ribbon {
  width: 288px;
  position: absolute;
  top: 123px;
  left: 250px;
  background: #000;
  font-family: 'Lobster Two', Helvetica, sans-serif;
  font-size: 30px;
  letter-spacing: 1px;
  font-style: italic;
  line-height: 60px;
  height: 60px;
  font-weight: normal;
}
.ribbon:before, .ribbon:after {
  content: '';
  position: absolute;
  display: block;
  border: 30px solid #333333;
  z-index: -1;
}
.ribbon:before {
  left: -33px;
  top: -10px;
  border-left-width: 15px;
  border-left-color: transparent;
}
.ribbon:after {
  right: -33px;
  bottom: -10px;
  border-right-width: 15px;
  border-right-color: transparent;
}

..但我无法控制两侧的宽度,使其看起来像这样:

enter image description here

1 个答案:

答案 0 :(得分:3)

您可以使用border-right-width上的::beforeborder-left-width:上的::after来实现此目的。至少,当我这样做时,它会在那支笔中起作用。

http://codepen.io/anon/pen/wHCeA

笔展示。