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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <header class="group">
  <nav>
    <h1><a href="#"><span>Diagonal Menu Buttons</span></a></h1>
    <ul>
      <li class="home selected"><a href="#"><span>Home</span></a></li>
      <li class="about"><a href="#"><span>About</span></a></li>
      <li class="work"><a href="#"><span>Work</span></a></li>
      <li class="contact"><a href="#"><span>Contact</span></a></li>
    </ul>
  </nav>
</header>
              
            
!

CSS

              
                @import "compass/css3";

@import url(https://fonts.googleapis.com/css?family=Cuprum);

$bg-color: #fafafa;
$font: 'Cuprum', sans-serif;

$padding: 1em;
$nav-bg: rgb(159,28,25);
$nav-highlight: lighten($nav-bg, 8%);
$nav-hover: lighten(saturate($nav-bg, 10%), 17%);
$nav-border: 1px solid lighten($nav-bg,45%);
$nav-color: lighten($nav-bg, 80%);

$skew-angle: 20deg;


* {
  box-sizing: border-box;
}

.group:after {
  content: "";
  display: table;
  clear: both;
}

/* General styling
----------------------- */
html { 
  background: $bg-color;
  font-size: 62.5%;
  -webkit-text-size-adjust: 100%; 
  -ms-text-size-adjust: 100%; 
  -webkit-font-smoothing: antialiased; 
}

body {
  font-family: $font;
  font-size: 1.6em;
  @media (min-width: 800px) {
    font-size: 2em;
  }
}

a {
  text-decoration: none;
}

/* Nav
------------------------ */

header {
  background: $nav-bg;
  overflow: hidden;
}

h1 {
  display: none;
  float: left;
  font-weight: bold;
  text-transform: uppercase;
  @media screen and (min-width: 41em) {
    display: block;
  }
}

nav {
  position: relative;
  float: left;
  left: 50%;
  max-width: 50em;
    @media screen and (min-width: 41em) {
      float: none;
      left: 0;
      margin-left: auto;
      margin-right: auto;
      padding: 0 $padding;
    }
}

nav ul {
  position: relative;
  float: left;
  left: -50%;
  margin-left: auto;
  margin-right: auto;
    @media screen and (min-width: 41em) {
      float: right;
      left: 0;
      margin-left: 0;
      margin-right: 0;
    }
}

nav li {
  float: left;
  position: relative;
  background: $nav-highlight;
}

nav ul li a, h1 a {
  display: block;
  padding: $padding;
  color: $nav-color;
}

/* Here we go! Time to skew. */
h1, nav li {
  border-right: $nav-border;
	transform: skewx(-$skew-angle);
  transition: background .2s ease, color .2s ease;
  &:hover {
    background: $nav-hover;
  }
}

h1, nav ul li:first-child {
  border-left: $nav-border;
}

/* Text, unskew thyself! (But unskeweth not the clickable areas.) */
nav span {
  display: block;
  transform: skewx($skew-angle);
}

.selected {
  background: $bg-color;
  a {
    color: $nav-highlight;
    &:hover {
      color: $nav-color;
    }
  }
}
              
            
!

JS

              
                /* The part that makes the diagonal stripes is near the bottom of the SCSS (line 102).

The trick to making the diagonal buttons is to use transform: skewx(n); on h1 and nav li, which creates the parallelograms. Then you apply transform: skewx(-n); to nav span. The spans are necessary because if you apply skewx(-n) to nav a, the links' clickable areas won't be skewed. You only want the text to be unskewed, not the links.

The whole thing gracefully degrades into a typical menu with rectangles if a browser doesn't support CSS transforms. */
              
            
!
999px

Console