<h1>Shadow ribbon</h1>
<nav class="ribbon ribbon--alpha ribbon--shadow" role="navigation" aria-label="breadcrumbs">
<a class="ribbon__element" href="https://www.silvestar.codes/" target="_blank">Home</a>
<a class="ribbon__element" href="https://www.silvestar.codes/categories/articles/" target="_blank">Blog</a>
<a class="ribbon__element" href="https://www.silvestar.codes/articles/building-an-animated-sticky-header-with-custom-offset/" aria-current="page" target="_blank">Post</a>
</nav>
<h3><a href="https://codepen.io/collection/DmwMyr/" target="_blank">A ribbon collection</a></h3>
<p><a href="https://www.silvestar.codes/" target="_blank">silvestar.codes</a> 🤘 <a href="https://play.silvestar.codes/ribbon/" target="_blank">SB Playground</a></p>
// Dirty reset
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
// Variables
$c0: #343435;
$c1: lighten(#0fba84, 5%);
$c2: lighten(#e01258, 10%);
$c3: lighten(#1ec9e4, 10%);
$c9: #fff;
// Global style
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: $c0;
min-height: 100vh;
padding: 10px;
font-family: 'Barlow', sans-serif;
}
h1,
h3,
p {
margin-top: 2em;
a {
color: $c2;
text-decoration: none;
&:hover {
color: darken($c2, 10%);
text-decoration: underline;
}
}
}
// Ribbon
.ribbon {
display: grid;
font-size: 15px;
grid-gap: 1px;
grid-template-columns: repeat(3, 1fr) 1em;
margin-left: auto;
margin-right: auto;
margin-top: 1em;
width: 100%;
}
.ribbon__element {
background-color: $c1;
color: $c9;
font-size: 1.5em;
font-weight: 700;
letter-spacing: 0.01em;
line-height: 1.333em;
padding: 0.667em 0.667em 0.667em 1.333em;
position: relative;
text-decoration: none;
&:nth-child(1) {
background-color: $c1;
z-index: 3;
}
&:nth-child(2) {
background-color: $c2;
z-index: 2;
}
&:nth-child(3) {
background-color: $c3;
z-index: 1;
}
.ribbon--alpha & {
&:before {
border-bottom: 1.333em solid transparent;
border-left: 0.667em solid $c9;
border-top: 1.333em solid transparent;
bottom: 0;
content: '';
height: 0;
left: 0;
position: absolute;
top: 0;
width: 0;
}
&: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;
transform: translateX(0.667em);
width: 0;
}
&:nth-child(1) {
&:after {
border-left-color: $c1;
}
}
&:nth-child(2) {
&:after {
border-left-color: $c2;
}
}
&:nth-child(3) {
&:after {
border-left-color: $c3;
}
}
}
.ribbon--shadow & {
box-shadow: 1px 3px 3px -3px black;
&:focus {
box-shadow: 1px 3px 3px -3px black, 0 -3px 0 0 $c0 inset;
}
}
&:hover,
&:active {
color: inherit;
text-decoration: underline;
}
&:focus {
outline: none;
}
&:visited {
color: $c9;
}
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.