cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <ul class="PrimaryNav with-indicator">
    <li class="Nav-item"><a href="#">Home</a></li>
    <li class="Nav-item"><a href="#">About</a></li>
    <li class="Nav-item is-active"><a href="#">Writing</a></li>
    <li class="Nav-item"><a href="#">Clients</a></li>
    <li class="Nav-item"><a href="#">Contact</a></li>
  </ul>
            
          
!
            
              @import url(https://fonts.googleapis.com/css?family=Open+Sans:800);

// How many menu items do we have?
$menu-items: 5;

// Colours
$background-color: #121212;
$indicator-color: #e82d00;

// Transition Speed
$transition-speed: 1.3s;

// Dynamic Variables
$width: (100/$menu-items) * 1%; // makes each item the right size
$menu-items-loop-offset: $menu-items - 1; // the number of items in the menu


// ======================================================
// Step 1 - Making a Fixed Width Navigation
// ======================================================

.PrimaryNav {
  @extend %cf; // clear the floats
  list-style: none;
  margin: 50px auto;
  max-width: 720px; // As all measurements are using % this could be a flexible value.
  padding: 0;
  width: 100%;
}

.Nav-item {
  background: #fff;
  display: block;
  float: left;
  margin: 0;
  padding: 0;
  width: $width; //dynamic width
  text-align: center;

  &:first-child {
    border-radius: 3px 0 0 3px;
  }

  &:last-child {
    border-radius: 0 3px 3px 0;
  }

  &.is-active a {
    color: $indicator-color;
  }

  a {
    color: $background-color;
    display: block;
    padding-top: 20px;
    padding-bottom: 20px;
    text-decoration: none;

    &:hover {
      color: $indicator-color;
    }
  }
}


// ======================================================
// Step 2 - Making the pseudo indicator
// ======================================================

.with-indicator {
  position: relative;// the menu is "relative" to the absolute position last-child pseudo elements.
  z-index: 0;

  .Nav-item {
    // ======================================================
    // Step 2.1 - Making the indicator with the pseudo element.
    // ======================================================
    &:last-child {
      &:before, &:after {
        content: '';
        display: block;
        position: absolute;
        transition: left #{$transition-speed} ease;
      }
      // Making the top CSS Triangle - learn more: https://css-tricks.com/animation-css-triangles-work/
      &:before {
        border: 6px solid transparent;
        border-top-color: $indicator-color;
        width: 0;
        height: 0;
        top: 0;
        left: ($width/2);
        margin-left: -3px;
      }
      &:after {
        background: $indicator-color;
        top: -6px;
        bottom: -6px;
        left: 0;
        width: $width;
        z-index: -1;
      }

    }

  }

}


// ======================================================
// The usual Global resets
// ======================================================

*, *:before, *:after {
  box-sizing: border-box; // learn more: https://css-tricks.com/box-sizing/
}

// Extending the https://css-tricks.com/micro-clearfix/
%cf:before,
%cf:after {
    content: " ";
    display: table;
}
%cf:after {
    clear: both;
}

// Presentation Styling

html {
  background-color: $background-color;
  font-family: 'Open Sans', sans-serif;
  font-weight: 800;
}
            
          
!
999px
Loading ..................

Console