Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h2>CSS <code>clip-path</code> Ribbons</h2>

<div class="samples">

  <div class="sample">
    <div class="ribbon">
      <div class="content">🕓</div>
    </div>
  </div>

  <div class="sample">
    <div class="ribbon slant-up" style="--color: #090909;">
      <div class="content">ok</div>
    </div>
  </div>

  <div class="sample">
    <div class="ribbon slant-down" style="--color: #8975b4;">
      <div class="content">2</div>
    </div>
  </div>

  <div class="sample">
    <div class="ribbon down" style="--color: #fd9c2e;">
      <div class="content">
        <svg width="24px" height="24px" aria-hidden="true" focusable="false" data-prefix="far" data-icon="star" class="svg-inline--fa fa-star fa-w-18" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512">
          <path fill="currentColor" d="M528.1 171.5L382 150.2 316.7 17.8c-11.7-23.6-45.6-23.9-57.4 0L194 150.2 47.9 171.5c-26.2 3.8-36.7 36.1-17.7 54.6l105.7 103-25 145.5c-4.5 26.3 23.2 46 46.4 33.7L288 439.6l130.7 68.7c23.2 12.2 50.9-7.4 46.4-33.7l-25-145.5 105.7-103c19-18.5 8.5-50.8-17.7-54.6zM388.6 312.3l23.7 138.4L288 385.4l-124.3 65.3 23.7-138.4-100.6-98 139-20.2 62.2-126 62.2 126 139 20.2-100.6 98z"></path>
        </svg>
      </div>
    </div>
  </div>

  <div class="sample">
    <div class="ribbon up" style="--color: #911750;">
      <div class="content">
        <svg width="24px" height="24px" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="times" class="svg-inline--fa fa-times fa-w-11" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 352 512">
          <path fill="currentColor" d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"></path>
        </svg>
      </div>
    </div>
  </div>

  <div class="sample">
    <div class="ribbon check" style="--color: #57c443;">
      <div class="content">
        <svg width="24px" height="24px" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="check" class="svg-inline--fa fa-check fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
          <path fill="currentColor" d="M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"></path>
        </svg>
      </div>
    </div>
  </div>

</div>
<small>Click the ribbons!</small>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css2?family=Lato:wght@100;300;400&display=swap");

body {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  font-family: "Lato";
  font-weight: 300;
  font-size: 24px;
  background: #2b2b2b;
  background-position: center center;
  background-size: 200%;
  background-image: url(https://images.unsplash.com/photo-1457062673746-3c8d0b60aa44?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1950&q=80);
  background-blend-mode: multiply;
}

h2, small  {
  display: block;
  color: white;
  font-weight: 300;
  margin-right: 2rem;
}

.samples {
  display: flex;
  flex-wrap: wrap;
  max-width: 480px;
}

.sample {
  border: 1px solid rgba(white, 0.2);
  width: 128px;
  height: 96px;
  position: relative;
  backdrop-filter: blur(4px);
  background: rgba(white, 0.2);
  box-shadow: 0px 0px 8px 2px rgba(black, 0.2);
  margin-right: 1rem; 
  margin-bottom: 1rem;
}

.ribbon {
  $default-right: 10px;
  $default-top: -3px;
  $default-color: #2ca7d8;
  $default-width: 32px;
  $default-height: 36px;
  
  position: absolute;
  right: var(--right, $default-right);
  top: var(--top, $default-top);
  
  filter: drop-shadow(2px 3px 2px rgba(black, 0.5));
  
  > .content {
    color: white;
    font-size: 1.25rem;
    text-align: center;
    font-weight: 400;
    background: var(--color, $default-color) linear-gradient(45deg, rgba(black, 0) 0%, rgba(white, 0.25) 100%);
    padding: 8px 2px 4px;
    
    
    clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 100%, 0 100%);
    
    width: var(--width, $default-width);
    min-height: var(--height, $default-height);
    
    transition: clip-path 1s, padding 1s, background 1s;
  }
  
  &.slant-up > .content {
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 12px), 50% calc(100% - 6px), 0 100%);
  }
  
  &.slant-down > .content {
    clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - 6px), 0 calc(100% - 12px));
  }
  
  &.down > .content {
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 8px), 50% 100%, 0 calc(100% - 8px));
  }
  
  &.up > .content {
    clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - 8px), 0 100%);
  }
  
  &.check > .content {
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 20px), 40% 100%, 0 calc(100% - 12px));
  }
}

              
            
!

JS

              
                const ribbons = document.querySelectorAll(".ribbon");
ribbons.forEach((ribbon) => {
  ribbon.addEventListener('click', (e) => {
     let target = e.target;
    while (target !== ribbon) {
      target = target.parentNode;
    }
    const types = ['', 'slant-up', 'slant-down', 'up', 'down', 'check'];
    const type = types[Math.floor(Math.random() * types.length)];
    target.className = `ribbon ${type}`;
  });
});
              
            
!
999px

Console