Simple Tab Creation using Css or Js






For supporting file is use in online link below :-


<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"/>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script>

HTML

<div class="box">
<ul>
<li id="tab-one" class="active">
<i class="fa fa-gift" aria-hidden="true"></i>
<h4>Tab -1</h4>
</li>
<li id="tab-two">
<i class="fa fa-gavel" aria-hidden="true"></i>
<h4>Tab -1</h4>
</li>

<li id="tab-three">
<i class="fa fa-folder-open" aria-hidden="true"></i>
<h4>Tab -1</h4>
</li>
        
<li id="tab-four">
<i class="fa fa-glass" aria-hidden="true"></i>
<h4>Tab -1</h4>
</li>
</ul>
<div class="content">
<div id="tab-one-content-box" class="hide active">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to mak</p>
</div>
<div id="tab-two-content-box" class="hide">
<p>
make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with 
</p>
</div>


<div id="tab-three-content-box" class="hide">
<p>software like Aldus PageMaker including versions of Lorem Ipsum.
<br>
Why do we use it?
<br>
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum </p>
</div>


<div id="tab-four-content-box" class="hide">
<p>letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
<br>
Where does it come from?
<br>
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney Coll
</p>
</div>
</div>
</div>



Css
-----------------
<style type="text/css">

body{ margin:0px; padding: 0px; font-family: sans-serif; background: #fff666}
.hide{ display: none;}
.active{ display: block;}
.box{ width: 800px; height: auto; margin: 150px auto; background-color:#e91e63; min-height: 200px; box-shadow: 0 5px 10px rgba(0,0,0,.5); }
.box ul{ margin: 0px; padding: 0px; list-style: none; display: flex; background-color: #fff;}
.box ul li{ margin: padding:5px; width: 25%; box-sizing: border-box; text-align: center; list-style: none;}
.box ul li .fa{ color: #262626; font-size: 36px;}
.box ul li h4{ margin: 0px; padding: 0px; color: #262626; font-size: 18px;}
.box ul li.active{ color:#e91e63;}
.box ul li.active .fa, .box ul li.active .h4{color: #e91e63;}
.content{ padding: 20px;}
.content p{ margin: 0px; padding: 0px; text-align: justify; color: #fff;}
</style>    


Js


-----------------
<script type="text/javascript">
$(document).ready(function(){
$(".box").on("click", "li", function(){
var tabId = $(this).attr("id");
$(this).addClass("active").siblings().removeClass("active");
$("#" + tabId + "-content-box").addClass("active").siblings().removeClass("active");
});

});
</script>





No comments:

Post a Comment