April 9, 201214 yr Hello, so im using fake tabs on my site. I have a navigation on each page that consists of 3 items. I want to be able to set the tab to be selected on load, on each of the different pages so it looks like the page is in that tab. Heres my html: <ul id="tabs"> <li><a href="index.php" title="tab1">Online Store</a></li> <li><a href="#" title="tab2">About</a></li> <li><a href="#" title="tab3">FAQ's</a></li> </ul> css: #tabs { overflow: auto; width: 100%; list-style: none; margin: 0; padding: 0; } #tabs li { margin: 0; padding: 0; float: left; } #tabs a { background-color:#000; color: #fff; float: left; font: bold 12px/35px 'Lucida sans', Arial, Helvetica; height: 40px; padding: 0 30px; text-decoration: none; } #tabs a:hover { background-image:url(http://subtlepatterns.com/patterns/concrete_wall.png); } #tabs a:focus { outline: 0; } #tabs #current a { background-image:url(http://subtlepatterns.com/patterns/concrete_wall.png); color: #fff; } In this one, i want the 'about' tab to have the selected state when it is on the page.
April 11, 201214 yr If I understand you correctly, and you just simply want to set the 'active' tab. Just modify your code slightly to the following: #tabs a#current { background-image:url(http://subtlepatterns.com/patterns/concrete_wall.png); color: #fff; } <ul id="tabs"> <li><a href="index.php" title="tab1">Online Store</a></li> <li><a href="#" title="tab2" id="current">About</a></li> <li><a href="#" title="tab3">FAQ's</a></li> </ul> So whichever tab link has the id "current" they will be displayed as 'active'
Create an account or sign in to comment