Skip to content

Instantly share code, notes, and snippets.

@shizonic
Created February 21, 2015 09:55
Show Gist options
  • Save shizonic/639effc2018058759248 to your computer and use it in GitHub Desktop.
Save shizonic/639effc2018058759248 to your computer and use it in GitHub Desktop.
Tabbed navigation (CSS only) // source http://jsbin.com/bamiwa
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tabbed navigation (CSS only)</title>
<link href='http://fonts.googleapis.com/css?family=Roboto:400,100,300,500,700,900' rel='stylesheet' type='text/css'>
<style id="jsbin-css">
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
height: 100%;
font-family: 'Roboto', sans-serif;
}
.tab {
display: none;
}
.tab + label {
text-align: center;
padding: 10px;
transition: all 200ms ease;
opacity: 0.7;
background: #eee;
cursor: pointer;
display: inline-block;
text-shadow: 1px 1px #ccc;
color: #000;
min-width: 120px;
box-shadow: 0 2px 6px rgba(0,0,0,0.2);
float: left;
}
.tab + label:hover {
opacity: 1.0;
}
.tab:checked + label {
opacity: 1.0;
background: #ccc;
box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.tab:checked + label + div {
display: block;
}
.tab + label + div {
display: none;
}
.content {
clear: both;
position: absolute;
padding: 50px 15px;
background: #fff;
width: 100%;
height: 100%;
background: #ccc;
z-index: -1;
}
</style>
</head>
<body>
<div id="wrapper">
<input type="radio" name="tab" class="tab" id="home" checked />
<label for="home">home</label>
<div class="content">
<h1>I am the content of home</h1>
</div>
<input type="radio" name="tab" class="tab" id="skills" />
<label for="skills">skills</label>
<div class="content">
<h1>I am the content of skills</h1>
</div>
<input type="radio" name="tab" class="tab" id="about" />
<label for="about">about</label>
<div class="content">
<h1>I am the content of about</h1>
</div>
<input type="radio" name="tab" class="tab" id="contact" />
<label for="contact">contact</label>
<div class="content">
<h1>I am the content of contact</h1>
</div>
</div>
<script id="jsbin-source-css" type="text/css">* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
height: 100%;
font-family: 'Roboto', sans-serif;
}
.tab {
display: none;
}
.tab + label {
text-align: center;
padding: 10px;
transition: all 200ms ease;
opacity: 0.7;
background: #eee;
cursor: pointer;
display: inline-block;
text-shadow: 1px 1px #ccc;
color: #000;
min-width: 120px;
box-shadow: 0 2px 6px rgba(0,0,0,0.2);
float: left;
}
.tab + label:hover {
opacity: 1.0;
}
.tab:checked + label {
opacity: 1.0;
background: #ccc;
box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.tab:checked + label + div {
display: block;
}
.tab + label + div {
display: none;
}
.content {
clear: both;
position: absolute;
padding: 50px 15px;
background: #fff;
width: 100%;
height: 100%;
background: #ccc;
z-index: -1;
}</script>
</body>
</html>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
height: 100%;
font-family: 'Roboto', sans-serif;
}
.tab {
display: none;
}
.tab + label {
text-align: center;
padding: 10px;
transition: all 200ms ease;
opacity: 0.7;
background: #eee;
cursor: pointer;
display: inline-block;
text-shadow: 1px 1px #ccc;
color: #000;
min-width: 120px;
box-shadow: 0 2px 6px rgba(0,0,0,0.2);
float: left;
}
.tab + label:hover {
opacity: 1.0;
}
.tab:checked + label {
opacity: 1.0;
background: #ccc;
box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.tab:checked + label + div {
display: block;
}
.tab + label + div {
display: none;
}
.content {
clear: both;
position: absolute;
padding: 50px 15px;
background: #fff;
width: 100%;
height: 100%;
background: #ccc;
z-index: -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment