Create Your Own Custom Tabbed Content
So you want to create your own tabs, eh? Recently a group member asked about creating their own tabbed content using images as the tabs. I posted the generic code needed to achieve the effect but decided it would make a neat little tip to put on the site as well.
Tabbed content is great for formatting groups of text into one neat, easy to read area.
And although there is speculation that Google will discount hidden text in its rankings, the majority of uses for tabs shouldn’t be in SEO critical pages anyways.
To start, I created two sections. In the first section I gave an ID of tabsection
and created one row with four columns. I each column I placed the image I wanted to use. The row has column container disabled, and marginless columns enabled.
For the second section I gave an ID of textsection
and created 4 rows to correspond with the 4 tab images. The content of these rows could be anything, but I stuck with a headline and text for simplicity. And the last 3 rows I gave the custom class hidden
to hide them by default. I also disabled column container in order to maintain their horizontal position during the fade effect.

The following CSS is used to style the tabs:
I’ve used comments to make it easier to understand. What we are essentially doing is animating the rows with position and transitions. In the hidden
class, we set an opacity to fade the text. If you prefer a sliding effect, simply replace that line with a top or left: -100%;
The custom jQuery needed is quite small and simple:
Index and eq are the magic functions in our javascript.
Instead of setting up a listener on each tab, we’re able to listen to the parent row and count which tab was clicked on, and apply the class to the corresponding row in order thanks to them.
Of course, there are dozens of way you can achieve custom tabs, this is just one way that I thought was easy to set up in X Theme. Hopefully, you find it useful!

Trying to accomplish this, but I believe I’m missing something…I’ve noticed in my tabbed content, I didn’t have hover links, whereas in the demo, you do…Also, how are you calling the specific text content? Are you doing this by giving making the images links, then giving them #ID’s that correspond with the ID of the text content?
Nope, no links needed, just the instructions above and the JS and CSS. The order of the columns in the first section will correspond to the order fo the rows in the second thanks to the JS. Just give the sections the appropriate IDs and you’re good to go.
Yeah, I go it to work…However, I’m using images in the text rows..When I select one, the image jumps a bit. R Anger said that it might possibly be because of the position:absolute in the hidden section? Here’s a link. http://109.199.111.197/~axentweb/test/window-tinting/
All code should be tweaked for specific use cases, of course. In your example, I would set #textsection .x-container to position: absolute, and add a height of 340px to #textsection
Works Perfectly. Thanks so much!
This was awesome. Really appreciated your help and it’s made my site look great. Thanks!
No problem, I’m glad it helped!
Hi there, I’m trying to achieve this style (no bacon just text boxes) on the left. Is it possible to get the code to do that?
Hey thanks for this! I was able to accomplish this pretty easily and it looks/functions great. Quick question though, is there anyway to link to having a specific tab open? For example, if someone clicks on url(.co)/#pastrami , it will open up on pastrami instead of the default bacon.
Also, is there a way for when someone clicks on an image, the page scrolls down to the content?
Thanks again!
Hey Julian,
You should be able to achieve the URL link with some extra JS:
[code]if ( window.location.hash ) {
$(window.location.hash).click(); //clicks on element specified by hash
}[/code]
Additionally, inside the click function you can add a scroll animation:
[code] $('html, body').animate({
scrollTop: $("#textsection").offset().top
}, 2000);[/code]
Hi Michael,
Thank you very much for sharing! I’m wondering how could I set up the content to close upon click on the same tab.
Keep up the good work.
Regards,
Jaime
Hi Jaime, that would take some customization of the main js function. You could add a class to the tab on click, then check for that class in the main function. Or check the textsection row and if it’s currently open, add the class hidden. Although I may opt to slide toggle them instead of hiding them at that point.
Good luck!
Excellent share thanks! – The only issue I have with it though is that it’s totally broken for mobile. The tabs don’t respond at all. Any fix?
Do you have a link? We’ve used it on mobile without issue, so we would need to figure out what’s happening.
Hi Michael,
This is really very cool and thanks for sharing this. It was very easy to recreate this on my site but I’m having one issue – in that when the page first loads all the content in the textsection appears until the user clicks one of the images in the tabsection. I added the ID’s at the section level for both text and tab and from row 2 – 4 added the id hidden but must have missed something. Any ideas?
hey Skeeter, sounds like a simple misstep, the hidden should be a class, not an ID š
oh geez! Let me try this right now
Worked like a champ and completely read class and dropped it into ID. One question for you if I want to reference these sections then would I just use the ID fields for each row them to make them directly accessible say via menu link say like http://www.website.com/#hotdog?
It will take a little extra code. Give each of the tab images (or the columns) an id, and then link to those IDs. Then, use the JS on the page to make it work: if ( window.location.hash ) { $(window.location.hash).click(); //clicks on element specified by hash } This will simulate a click on the tab based on the URL hash. Important to note is it wont work on the nav items once you’re currently on the page. For that you would need another script to detect click on the nav elements themselves, and then simulate the click on the… Read more »
Cool! Thanks I’ll attempt this. Really appreciate the support Michael.
Hey Micheal, I need a bit more advice as I am running into the following:
I have implemented the custom image tab on the following two pages. But what I am running into is that each tab has a video yet they all want to play the far video on the right hand side (tab 4) verse the tab that is exposed. Any Ideas on how to fix this?
http://298.e0e.myftpupload.com/who-we-serve/
http://298.e0e.myftpupload.com/services/
Nice find. Add this to #textsection .hidden:
z-index: -1;
Thank you! Your suggestion fixed it! š
That section now looks like this:
#textsection .hidden {
position: absolute;
left: 0;
right: 0;
opacity: 0;
-webkit-transition: all 0.7s cubic-bezier(0.23, 1, 0.32, 1);
transition: all 0.7s cubic-bezier(0.23, 1, 0.32, 1);
z-index: -1;
}
Hi Michael, some great stuff!
I am having one issue. The content for the first corresponding icon shows as expected but if I click on the first icon it shows the second row of content and each following icons loads one off; click on icon 1 and it shows content 2, click on icon 2 and it shows content 3….
Any thoughts on how to correct?
Thank you.
Hey Chad,
It looks like I might have put the wrong code into my gist. Do my a favour, change the
eq(textshow)
toeq(textshow - 1)
and let me know if that works for you.