JSFiddle - React, Tailwind, and code Playground
HTML
<div id="example-two">
<ul class="nav">
<li class="nav-one"><a href="#featured" class="current">Facebook comment</a></li>
<li class="nav-two"><a href="#core">Google comment</a></li>
<li class="nav-three"><a href="#hard">Record</a></li>
</ul>
<div class="list-wrap">
<div id="featured">
value 1
</div>
<div id="core" class="hide">
<script src='https://apis.google.com/js/plusone.js'></script>
<div id='comments'/>
</div>
<div id="hard" class="hide">
value 3
</div>
</div> <!-- END List Wrap -->
</div> <!-- END Organic Tabs (Example One) -->
CSS
/*
Organic Tabs
by Chris Coyier
http://css-tricks.com
*/
* { margin: 0; padding: 0; }
body { font: 12px Georgia, serif; }
html { overflow-y: scroll; }
a { text-decoration: none; }
a:focus { outline: 0; }
p { font-size: 15px; margin: 0 0 20px 0; }
#page-wrap { width: 440px; margin: 80px auto; }
h1 { font: bold 40px Sans-Serif; margin: 0 0 20px 0; }
/* Generic Utility */
.hide { position: absolute; top: -9999px; left: -9999px; }
/* Specific to example one */
#erhaytab { background: #eee; padding: 10px; margin: 0 0 20px 0; -moz-box-shadow: 0 0 5px #666; -webkit-box-shadow: 0 0 5px #666; }
#erhaytab .nav { overflow: hidden; margin: 0 0 10px 0; }
#erhaytab .nav li { width: 97px; float: left; margin: 0 10px 0 0; }
#erhaytab .nav li.last { margin-right: 0; }
#erhaytab .nav li a { display: block; padding: 5px; background: #959290; color: white; font-size: 10px; text-align: center; border: 0; }
#erhaytab .nav li a:hover { background-color: #111; }
#erhaytab ul { list-style: none; }
#erhaytab ul li a { display: block; border-bottom: 1px solid #666; padding: 4px; color: #666; }
#erhaytab ul li a:hover { background: #fe4902; color: white; }
#erhaytab ul li:last-child a { border: none; }
#erhaytab ul li.nav-one a.current, #erhaytab ul.featured li a:hover { background-color: #0575f4; color: white; }
#erhaytab ul li.nav-two a.current, #erhaytab ul.core li a:hover { background-color: #d30000; color: white; }
#erhaytab ul li.nav-three a.current, #erhaytab ul.jquerytuts li a:hover { background-color: #8d01b0; color: white; }
#erhaytab ul li.nav-four a.current, #erhaytab ul.classics li a:hover { background-color: #FE4902; color: white; }
/* Specific to example two */
#example-two .list-wrap { background: #eee; padding: 10px; margin: 0 0 15px 0; }
#example-two ul { list-style: none; }
#example-two ul li a { display: block; border-bottom: 1px solid #666; padding: 4px; color: #666; }
#example-two ul li a:hover { background: #333; color: white; }
#example-two ul...
JavaScript
(function($) {
$.organicTabs = function(el, options) {
var base = this;
base.$el = $(el);
base.$nav = base.$el.find(".nav");
base.init = function() {
base.options = $.extend({},$.organicTabs.defaultOptions, options);
// Accessible hiding fix
$(".hide").css({
"position": "relative",
"top": 0,
"left": 0,
"display": "none"
});
base.$nav.delegate("li > a", "click", function() {
// Figure out current list via CSS class
var curList = base.$el.find("a.current").attr("href").substring(1),
// List moving to
$newList = $(this),
// Figure out ID of new list
listID = $newList.attr("href").substring(1),
// Set outer wrapper height to (static) height of current inner list
$allListWrap = base.$el.find(".list-wrap"),
curListHeight = $allListWrap.height();
$allListWrap.height(curListHeight);
if ((listID != curList) && ( base.$el.find(":animated").length == 0)) {
// Fade out current list
base.$el.find("#"+curList).fadeOut(base.options.speed, function() {
// Fade in new list on callback
base.$el.find("#"+listID).fadeIn(base.options.speed);
// Adjust outer wrapper to fit new list snuggly
var newHeight = base.$el.find("#"+listID).height();
$allListWrap.animate({
height: newHeight
...