Skip to content

Instantly share code, notes, and snippets.

@RuanAragao
Last active December 17, 2015 17:09
Show Gist options
  • Save RuanAragao/5644412 to your computer and use it in GitHub Desktop.
Save RuanAragao/5644412 to your computer and use it in GitHub Desktop.
Tabs navigable - Only CSS3
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Tabs navigable - Only CSS3</title>
</head>
<body>
<nav class="nav">
<ul>
<li><a href="#p1">1</a></li>
<li><a href="#p2">2</a></li>
<li><a href="#p3">3</a></li>
</ul>
</nav>
<section class="box">
<div id="p1">abc</div>
<div id="p2">def</div>
<div id="p3">ghi</div>
</section>
</body>
</html>
.nav {
width: 350px;
height: 20px;
padding-bottom: 10px;
clear: both;
background-image: linear-gradient(to bottom, #ccc, #e7e7e7, #ccc);
}
.nav li {
float: left;
list-style-type: none;
}
.nav li a {
color: #333;
text-decoration: none;
float: left;
padding: 5px 10px;
}
.nav li a:hover {
color: white;
background: #aaa;
}
.box div {
width: 340px;
height: 240px;
position: absolute;
padding: 5px;
background-color: #eee;
}
.box div:nth-child(1) {z-index: 3} /* number max of tabs */
.box div[id^="p"]:target:nth-child(2), /* tab 2 */
.box div[id^="p"]:target:nth-child(3) { /* tab 3 */
z-index: 3; /* number max of tabs */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment