Skip to content

Instantly share code, notes, and snippets.

@shizonic
Created February 21, 2015 09:46
Show Gist options
  • Save shizonic/0a3654e0f958af6fa20e to your computer and use it in GitHub Desktop.
Save shizonic/0a3654e0f958af6fa20e 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 150ms ease;
opacity: 0.9;
background: #eee;
cursor: pointer;
display: inline-block;
text-shadow: 1px 1px #ccc;
color: #000;
min-width: 120px;
}
.tab + label:hover {
opacity: 1.0;
}
.tab:checked + label {
opacity: 1.0;
background: #ccc;
}
.tab:checked + label + div {
display: block;
}
.tab + label + div {
display: none;
}
.content {
position: absolute;
padding: 15px;
box-shadow: 0 2px 6px rgba(0,0,0,0.2);
background: #fff;
width: 100%;
height: 100%;
}
</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 150ms ease;
opacity: 0.9;
background: #eee;
cursor: pointer;
display: inline-block;
text-shadow: 1px 1px #ccc;
color: #000;
min-width: 120px;
}
.tab + label:hover {
opacity: 1.0;
}
.tab:checked + label {
opacity: 1.0;
background: #ccc;
}
.tab:checked + label + div {
display: block;
}
.tab + label + div {
display: none;
}
.content {
position: absolute;
padding: 15px;
box-shadow: 0 2px 6px rgba(0,0,0,0.2);
background: #fff;
width: 100%;
height: 100%;
}</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 150ms ease;
opacity: 0.9;
background: #eee;
cursor: pointer;
display: inline-block;
text-shadow: 1px 1px #ccc;
color: #000;
min-width: 120px;
}
.tab + label:hover {
opacity: 1.0;
}
.tab:checked + label {
opacity: 1.0;
background: #ccc;
}
.tab:checked + label + div {
display: block;
}
.tab + label + div {
display: none;
}
.content {
position: absolute;
padding: 15px;
box-shadow: 0 2px 6px rgba(0,0,0,0.2);
background: #fff;
width: 100%;
height: 100%;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment