- Overview
- Documents
Responsive Tabs is a simple to use, alternative, lightweight and responsive jQuery Tabs plugin.
Browser Compatibility
- IE 8+
- Firefox
- Chrome
- Safari
- Opera
- Most mobile browsers
Source: github.com
1. INCLUDE CSS AND JS FILES
<link href="assets/css/responsive-tabs.css" rel="stylesheet" type="text/css" media="all" /> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script> <script src="assets/js/responsive-tabs.min.js" type="text/javascript"></script>
2. HTML
<ul class="responsive-tabs"> <li><a href="#example-1-tab-1" target="_self">Tab One</a></li> <li><a href="#example-1-tab-2" target="_self">Tab Two</a></li> <li><a href="#example-1-tab-3" target="_self">Tab Three</a></li> </ul> <div class="responsive-tabs-content bm-larger"> <div id="example-1-tab-1" class="responsive-tabs-panel"> <div class="responsive-tab-title"></div> <p> <a href="#example-1-tab-2" target="_self" class="responsive-tabs-panel-link">Inner link to Tab Two</a>. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus ac fringilla nulla, sit amet consequat eros. Pellentesque pharetra blandit commodo. Phasellus massa nisl, feugiat ac bibendum et, dictum id ipsum. Quisque sit amet accumsan tortor. Etiam luctus, est ac iaculis posuere, justo elit aliquam risus, a interdum odio elit eleifend nisl. In vulputate lobortis lectus in eleifend. Etiam eget luctus sapien. Curabitur auctor volutpat enim sit amet vulputate. Nullam fringilla odio eu nisl tempus venenatis. Aliquam scelerisque ut lacus rhoncus hendrerit. Sed ut dolor et lorem faucibus imperdiet. Vivamus suscipit cursus sagittis. In sit amet dolor odio. Interdum et malesuada fames ac ante ipsum primis in faucibus. Cras eget convallis lorem. </p> </div> <div id="example-1-tab-2" class="responsive-tabs-panel"> <div class="responsive-tab-title"></div> <p> <a href="#example-1-tab-1" target="_self" class="responsive-tabs-panel-link">Inner link to Tab One</a>. Cras sagittis neque id tortor dictum tincidunt. Nulla volutpat cursus metus, sed pulvinar nibh vulputate a. Curabitur tristique pharetra elit quis tincidunt. Nulla sed libero hendrerit, condimentum velit tincidunt, sollicitudin tortor. Nulla volutpat lacinia tortor. Aenean auctor consectetur adipiscing. Proin venenatis, lacus in lacinia dapibus, urna lectus euismod erat, mollis vehicula diam elit sed est. Integer libero ligula, tincidunt eget tincidunt ut, dignissim quis sem. Sed interdum auctor lacus id malesuada. Aenean in mauris ac sapien auctor ultrices at pretium dui. Maecenas nec dictum turpis. Nam ipsum sapien, commodo at ligula ut, lobortis congue ante. Sed tincidunt dolor vitae libero congue pulvinar. In ultricies arcu vitae leo feugiat dignissim. Suspendisse potenti. Vivamus et ornare eros. </p> </div> <div id="example-1-tab-3" class="responsive-tabs-panel"> <div class="responsive-tab-title"></div> <p> Mauris vel placerat dolor. Morbi mattis venenatis feugiat. Vivamus nunc diam, luctus id ipsum ut, tempor pharetra augue. Ut sagittis orci at posuere venenatis. Fusce at aliquam lacus. Sed id augue nisl. Nunc vitae ultricies dolor. Etiam rhoncus felis eget vulputate suscipit. Praesent convallis bibendum urna, ultricies consequat enim ullamcorper et. Fusce scelerisque dolor ut porta bibendum. Sed felis quam, vulputate cursus massa ac, sodales ullamcorper mauris. </p> </div> </div>
Usage
- Link both the 'responsive-tabs.css' and 'responsive-tabs.js' files into your document
- Place an unordered list and give it a class name 'responsive-tabs'
- In each list item place a hyperlink
- Give the hyperlinks 'href' attribute a _unique_ anchor
- Place a div after your unordered list with a class name 'responsive-tabs-content'
- Inside that div place another div with a class name 'responsive-tabs-panel'
- Place a 'responsive-tabs-panel' div for each of the list items using the unique 'href' as that div's 'id' attribute
Since unordered lists are hidden in smaller devices, we use another div with a class of 'responsive-tab-title' within each 'responsive-tabs-panel' to place the list items hyperlink display text
You can also change the position of your tabs' links by adding the class 'responsive-tabs-left' or 'responsive-tabs-right' to both the 'responsive-tabs' and 'responsive-tabs-content' elements.
If you wish to change the status of a panel with a hyperlink from within the panel itself, give that link a class name of 'responsive-tabs-panel-link' and set the URL to the unique 'id' of the panel you wish to display.