JSFiddle - React, Tailwind, and code Playground
by Front Dev
HTML
<ul class="tabs">
<li class="active" rel="tab1">Tab 1</li>
<li rel="tab2">Tab 2</li>
<li rel="tab3">Tab 3</li>
<li rel="tab4">Tab 4</li>
</ul>
<div class="tab_container">
<h3 class="d_active tab_drawer_heading" rel="tab1">Tab 1</h3>
<div id="tab1" class="tab_content">
<img id="Image-Maps-Com-image-maps-2014-10-29-064734" src="http://www.image-maps.com/m/private/0/hi9okpic7dl52aogke435dk0f5_map-pin-760x508.jpg" border="0" usemap="#image-maps-2014-10-29-064734" alt="" />
<map name="image-maps-2014-10-29-064734" id="ImageMapsCom-image-maps-2014-10-29-064734">
<area alt="" title="" href="#" shape="rect" coords="212,156,295,245" style="outline:none;" target="_self" onclick="aaa" />
<area alt="" title="" href="#" shape="rect" coords="484,142,567,231" style="outline:none;" target="_self" />
<area shape="rect" coords="758,506,760,508" alt="Image Map" style="outline:none;" title="Image Map" href="http://www.image-maps.com/index.php?aff=mapped_users_0" />
</map>
</div>
<!-- #tab1 -->
<h3 class="tab_drawer_heading" rel="tab2">Tab 2</h3>
<div id="tab2" class="tab_content">
<img id="Image-Maps-Com-image-maps-2014-10-29-064734" src="http://www.image-maps.com/m/private/0/hi9okpic7dl52aogke435dk0f5_map-pin-760x508.jpg" border="0" usemap="#image-maps-2014-10-29-064734" alt="" />
<map name="image-maps-2014-10-29-064734" id="ImageMapsCom-image-maps-2014-10-29-064734">
<area alt="" title="" href="#" shape="rect" coords="212,156,295,245" style="outline:none;" target="_self" onclick="aaa" />
<area alt="" title="" href="#" shape="rect" coords="484,142,567,231" style="outline:none;" target="_self" />
<area shape="rect" coords="758,506,760,508" alt="Image Map" style="outline:none;" title="Image Map" href="http://www.image-maps.com/index.php?aff=mapped_users_0" />
</map>
</div>
<!-- #tab2 -->
<h3 class="tab_drawer_heading" rel="tab3">Tab 3</h3>
<div id="tab3" class="tab_content">
<img id="Image-Maps-Com-image-maps-2014-10-29-064734"...
CSS
ul.tabs {
margin: 0;
padding: 0;
float: left;
list-style: none;
height: 32px;
border-bottom: 1px solid #333;
width: 100%;
}
ul.tabs li {
float: left;
margin: 0;
cursor: pointer;
padding: 0px 21px;
height: 31px;
line-height: 31px;
border-top: 1px solid #333;
border-left: 1px solid #333;
border-bottom: 1px solid #333;
background-color: #666;
color: #ccc;
overflow: hidden;
position: relative;
}
.tab_last { border-right: 1px solid #333; }
ul.tabs li:hover {
background-color: #ccc;
color: #333;
}
ul.tabs li.active {
background-color: #fff;
color: #333;
border-bottom: 1px solid #fff;
display: block;
}
.tab_container {
border: 1px solid #333;
border-top: none;
clear: both;
float: left;
width: 100%;
background: #fff;
overflow: auto;
}
.tab_content {
padding: 20px;
display: none;
}
.tab_drawer_heading { display: none; }
@media screen and (max-width: 480px) {
.tabs {
display: none;
}
.tab_drawer_heading {
background-color: #ccc;
color: #fff;
border-top: 1px solid #333;
margin: 0;
padding: 5px 20px;
display: block;
cursor: pointer;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.d_active {
background-color: #666;
color: #fff;
}
}
JavaScript
$(document).ready(function(e) {
// tabbed content
$(".tab_content").hide();
$(".tab_content:first").show();
/* if in tab mode */
$("ul.tabs li").click(function() {
$(".tab_content").hide();
var activeTab = $(this).attr("rel");
$("#"+activeTab).fadeIn();
$("ul.tabs li").removeClass("active");
$(this).addClass("active");
$(".tab_drawer_heading").removeClass("d_active");
$(".tab_drawer_heading[rel^='"+activeTab+"']").addClass("d_active");
});
/* if in drawer mode */
$(".tab_drawer_heading").click(function() {
$(".tab_content").hide();
var d_activeTab = $(this).attr("rel");
$("#"+d_activeTab).fadeIn();
$(".tab_drawer_heading").removeClass("d_active");
$(this).addClass("d_active");
$("ul.tabs li").removeClass("active");
$("ul.tabs li[rel^='"+d_activeTab+"']").addClass("active");
});
/* Extra class "tab_last"
to add border to right side
of last tab */
$('ul.tabs li').last().addClass("tab_last");
$('img[usemap]').rwdImageMaps();
});