Skip to content

Instantly share code, notes, and snippets.

@schadeck
Forked from LeaVerou/dabblet.css
Created October 21, 2013 14:39
Show Gist options
  • Save schadeck/7084965 to your computer and use it in GitHub Desktop.
Save schadeck/7084965 to your computer and use it in GitHub Desktop.
Slanted tabs with CSS 3D transforms
/**
* Slanted tabs with CSS 3D transforms
* See http://lea.verou.me/2013/10/slanted-tabs-with-css-3d-transforms/
*/
body { padding: 50px; }
nav {
position: relative;
z-index: 1;
white-space: nowrap;
}
nav a {
position: relative;
display: inline-block;
padding: 1.5em 1.5em 1em;
color: inherit;
text-decoration: none;
margin: 0 -7px;
}
nav a::before,
main {
border: .1em solid #aaa;
}
nav a::before {
content: ''; /* To generate the box */
position: absolute;
top: 0; right: 0; bottom: .5em; left: 0;
z-index: -1;
border-bottom: none;
border-radius: 10px 10px 0 0;
background: #ddd;
box-shadow: 0 2px hsla(0,0%,100%,.5) inset;
transform: perspective(5px) rotateX(2deg);
transform-origin: bottom;
}
nav.left a {
padding: 1.5em 2em 1em 1em;
}
nav.left a::before {
transform-origin: bottom left;
}
nav.right a {
padding: 1.5em 1em 1em 2em;
}
nav.right a::before {
transform-origin: bottom right;
}
nav a.selected {
z-index: 2;
}
nav a.selected::before {
margin-bottom: -1px;
border-top-width: 1px;
}
nav a.selected::before,
main {
background: #eee;
}
main {
display: block;
margin: -8px 0 30px -15px;
padding: 1em;
border-radius: 3px;
}
<!-- This HTML is invalid and just for demo purposes. Don't use multiple main elements! -->
<nav>
<a href="#">Home</a>
<a href="#" class="selected">Projects</a>
<a href="#">About</a>
</nav>
<main>
Content area
</main>
<nav class="left">
<a href="#">Home</a>
<a href="#" class="selected">Projects</a>
<a href="#">About</a>
</nav>
<main>
Content area
</main>
<nav class="right">
<a href="#">Home</a>
<a href="#" class="selected">Projects</a>
<a href="#">About</a>
</nav>
<main>
Content area
</main>
// alert('Hello world!');
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"all"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment