Search code examples
cssshapescss-shapes

CSS Ribbon - controlling the width of the sides


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

.. but I can't quite control the width of the sides to make it look like this:

enter image description here


Solution

  • You can achieve this with border-right-width on ::before and border-left-width: on ::after. At least, it works in that pen when I do that.

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

    Pen demonstrating.