<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>
@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;
}
}
}
View Compiled
/* 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. */
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.