About The jQuery Tab Slider
The jQuery Tab Slider was built for a recent project that required a tab interface, but it's animation needed to flow smoothly, almost like a slideshow. I was able to create this plugin for just that; and rather than only use the plugin on one website I thought that I would share it with the world.
Current Version: 1.0 - 5/13/2013
jQuery Tab Slider Example
Download jQuery Tab Slider
Thank you for taking interest in jQuery Tab Slider!
Included in the zip file is:
- example.html - A working example
- jQuery.tab-slider.js - The core Tab Slider JavaScript file
- tab-slide-style.css - The StyleSheet used for the base template
Click to download, obviously!
Download - 1.70kb
jQuery Tab Slider Instructions
Insert The Script
To use the jQuery Tab Slider you will need to link to the JS file by placing this near the closeing </body> tag. Be sure that it is placed after your link to jQuery.
<script type="text/javascript" src="jQuery.tab-slider.js"></script>
Insert the HTML
Once you have the script linked up, you can start to format your html. If you copy and paste the HTML from below and the provided CSS file, you should have a working Tab Slider that looks like the example.
<div id="tab-slider"> <div class="tab-nav"> <ul class="tab-nav"> <li class="tab active"><a class="tab-link" href="#section1" rel="1">Section 1</a></li> <li class="tab"><a class="tab-link" href="#section2" rel="2">Section 2</a></li> <li class="tab"><a class="tab-link" href="#section3" rel="3">Section 3</a></li> </ul> </div> <div class="tab-main-content"> <div class="tab-slider-wrapper"> <div class="tab-content" id="section1"> Section 1 </div> <div class="tab-content" id="section2"> Section 2 </div> <div class="tab-content" id="section3"> Section 3 </div> </div> </div> </div>
After inserting the code above, you need to adjust the Navigation and Sections based on what your needs are. The setup from above is for three sections. For two or less, just delete the <li> with the Navigation you do not need and the section div that relates to it. Be sure that you are setting the rel tag based on what section number it links to. Without the rel tags, the slider will not work
Configure jQuery Tab Slider
Once you get all of your code in place you will need to configure Tab Slider. First you will need to adjust the "width" setting in jQuery.tab-slider.js. Set this to the width in pixels that matches #tab-slider in the included CSS file.
var $width = 700, //The width in pixels of your #tab-slider $tabs = $('.tab'), //Your Navigation Class Name $delay = 600; //Pause time between animation in Milliseconds
You will also need to set a width for the #tab-content in the CSS file. In the working example I have it set to 14 pixels less then the full width, this is to accommodate for the 7 pixel padding I added. You need to only adjust the height in the CSS file.
#tab-slider { width:700px; height:400px; margin: 0 auto; position:relative; overflow:hidden; border:1px solid #555;} .tab-content { padding:7px; height:386px; width:686px; overflow:hidden; float: left;}
jQuery Tab Slider Support
Are you having an issue implementing the jQuery Tab Slider? Or do you just have a general question about the plugin? If so, you can email me by following this link.