Created
October 16, 2014 09:01
-
-
Save suhaotian/43070b085e46afa41d36 to your computer and use it in GitHub Desktop.
// source http://jsbin.com/sivace/1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style id="jsbin-css"> | |
.tabs { | |
position: relative; | |
width: 25em; | |
list-style: none; | |
padding: 0; | |
} | |
.tabs li { | |
float: left; | |
} | |
.trigger { | |
color: #aaa; | |
text-decoration: none; | |
text-transform: uppercase; | |
font-weight: bold; | |
width: 4em; | |
display: block; | |
padding: 0 .5em; | |
} | |
li:first-child .trigger { | |
margin-left: 4em; | |
} | |
li:last-child .trigger { | |
position: absolute; | |
left: 0; | |
} | |
.content { | |
display: none; | |
position: absolute; | |
top: 2em; | |
left: 0; | |
padding: 0 .5em; | |
} | |
li:target .content, | |
li:last-child .content { | |
display: block; | |
} | |
li:target .trigger, | |
li:last-child .trigger { | |
color: #000; | |
} | |
li:target ~ li:last-child .content { | |
display: none; | |
} | |
li:target ~ li:last-child .trigger { | |
color: #aaa; | |
} | |
</style> | |
<ul class="tabs"> | |
<li id="tab2"> | |
<a href="#tab2" class="trigger">Tab 2</a> | |
<div class="content"> | |
Content 2 | |
</div> | |
</li> | |
<li id="tab3"> | |
<a href="#tab3" class="trigger">Tab 3</a> | |
<div class="content"> | |
Content 3 | |
</div> | |
</li> | |
<li id="tab1"> | |
<a href="#tab1" class="trigger">Tab 1</a> | |
<div class="content"> | |
Content 1 | |
</div> | |
</li> | |
</ul> | |
<script id="jsbin-source-css" type="text/css">.tabs { | |
position: relative; | |
width: 25em; | |
list-style: none; | |
padding: 0; | |
} | |
.tabs li { | |
float: left; | |
} | |
.trigger { | |
color: #aaa; | |
text-decoration: none; | |
text-transform: uppercase; | |
font-weight: bold; | |
width: 4em; | |
display: block; | |
padding: 0 .5em; | |
} | |
li:first-child .trigger { | |
margin-left: 4em; | |
} | |
li:last-child .trigger { | |
position: absolute; | |
left: 0; | |
} | |
.content { | |
display: none; | |
position: absolute; | |
top: 2em; | |
left: 0; | |
padding: 0 .5em; | |
} | |
li:target .content, | |
li:last-child .content { | |
display: block; | |
} | |
li:target .trigger, | |
li:last-child .trigger { | |
color: #000; | |
} | |
li:target ~ li:last-child .content { | |
display: none; | |
} | |
li:target ~ li:last-child .trigger { | |
color: #aaa; | |
}</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.tabs { | |
position: relative; | |
width: 25em; | |
list-style: none; | |
padding: 0; | |
} | |
.tabs li { | |
float: left; | |
} | |
.trigger { | |
color: #aaa; | |
text-decoration: none; | |
text-transform: uppercase; | |
font-weight: bold; | |
width: 4em; | |
display: block; | |
padding: 0 .5em; | |
} | |
li:first-child .trigger { | |
margin-left: 4em; | |
} | |
li:last-child .trigger { | |
position: absolute; | |
left: 0; | |
} | |
.content { | |
display: none; | |
position: absolute; | |
top: 2em; | |
left: 0; | |
padding: 0 .5em; | |
} | |
li:target .content, | |
li:last-child .content { | |
display: block; | |
} | |
li:target .trigger, | |
li:last-child .trigger { | |
color: #000; | |
} | |
li:target ~ li:last-child .content { | |
display: none; | |
} | |
li:target ~ li:last-child .trigger { | |
color: #aaa; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment