SB Playground

A showcase of demos, examples, and code snippets of one SB.
The source code for the site could be found here.

Alpha Ribbon

A ribbon made with CSS triangles and pseudo-classes.

Modifier: .ribbon--alpha.

The HTML structure:

<nav class="ribbon ribbon--alpha" role="navigation" aria-label="breadcrumbs">
  <a class="ribbon__element" href="https://www.silvestar.codes/">Home</a>
  <a class="ribbon__element" href="https://www.silvestar.codes/categories/articles/">Blog</a>
  <a class="ribbon__element" href="https://www.silvestar.codes/articles/building-an-animated-sticky-header-with-custom-offset/" aria-current="page">Post</a>
</nav>

The CSS code:

/* The left triangle */
.ribbon--alpha .ribbon__element:before {
  border-bottom: 1.333em solid transparent;
  border-left: 0.667667em solid #fff;
  border-top: 1.333em solid transparent;
  bottom: 0;
  content: '';
  height: 0;
  left: 0;
  position: absolute;
  top: 0;
  width: 0;
}

/* The right triangle */
.ribbon--alpha .ribbon__element:after {
  border-bottom: 1.333em solid transparent;
  border-left: 0.667em solid;
  border-top: 1.333em solid transparent;
  bottom: 0;
  content: '';
  height: 0;
  position: absolute;
  right: 0;
  top: 0;
  -webkit-transform: translateX(0.667667em);
  -ms-transform: translateX(0.667667em);
  transform: translateX(0.667667em);
  width: 0;
}

/* Match background color for right triangles */
.ribbon--alpha .ribbon__element:nth-child(1):after {
  border-left-color: #11d295;
}

.ribbon--alpha .ribbon__element:nth-child(2):after {
  border-left-color: #ef3675;
}

.ribbon--alpha .ribbon__element:nth-child(3):after {
  border-left-color: #4cd4e9;
}

A ribbon component showed in these examples should be used as a breadcrumb element. However, if you want to use it for something else, be sure to update or remove the aria attributes. The HTML code for accessible breadcrumbs could be found on the A11y Style Guide website, under Option #2.

See the full list of ribbon modifiers below:

Powered by Starter Project.