Skip to content

Instantly share code, notes, and snippets.

@davidglezz
Forked from LeaVerou/dabblet.css
Last active September 24, 2017 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidglezz/58847c291a47e40283fc to your computer and use it in GitHub Desktop.
Save davidglezz/58847c291a47e40283fc 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: -0.1em;
border-top-width: 0.1em;
}
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":"80","seethrough":"","prefixfree":"1","page":"css"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment