Home arrow Style Sheets arrow Page 3 - Tabbed Browsing with CSS2
STYLE SHEETS

Tabbed Browsing with CSS2


So you've created one sweet web application, and you're very proud of the functionality, but the User Interface is somewhat lacking. Hey, don't worry, it happens to all of us. We are programmers after all, not UI designers! But don't despair; this tutorial will show you how to separate the pages of your application into ergonomically distinct chunks, by the use of CSS tabs. That's right, CSS, no tables involved!

Author Info:
By: Justin Cook
Rating: 4 stars4 stars4 stars4 stars4 stars / 19
July 28, 2004
TABLE OF CONTENTS:
  1. · Tabbed Browsing with CSS2
  2. · The Style
  3. · Conclusion and All the Code

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Tabbed Browsing with CSS2 - Conclusion and All the Code
(Page 3 of 3 )

So you've seen that with a minimal amount of code, you can generate ergonomic, table-less tabs. And we did it all with a very basic array iteration, and a bit of CSS. This will no doubt increase the usability of your application ten-fold.

There is a chance that you're not quite satisfied with the flat-looking tabs, despite their advantages of easy configuration and fast loading. That's probably because you've seen tabs out there that look quite fancy, employing the use of 3D-looking buttons (like www.no-ip.com). Well, if you're interested in graduating to the next level of tabbing, stay tuned for my next article, which will explain how to create the 3D tabs in FireWorks, slice them up, and apply them to your tab structure in an extremely flexible and manageable way.

But until then, have fun with your new knowledge of table-less tab creation!

All the Code:

<style>
#navTabs {
font-family: verdana;
padding: 0px 0px 0px 15px;
margin: 0px;
width: 100%;
height: 30px;
vertical-align: middle;
border-color: #333333;
border-style: solid;
border-width: 0px 0px 2px 0px;
}


.tabon, .taboff {
height: 30px;
cursor: pointer;
cursor: hand;
display: inline;
overflow: hidden;
vertical-align: top;
font-size: 11px;
padding: 6px 2px 0px 2px;
margin: 0px 2px;
border-color: #333333;
border-style: solid;
border-width: 1px 1px 0px 1px;
}


.tabOn {
font-weight: bold;
position: relative;
top: 2px;
background: #ffffff;
border-width: 2px 2px 0px 2px;
}


.taboff {
color: #666666;
background: #dddddd;
}

</style>

<%
dim arTabs( 5 )
arTabs( 0 ) = "home"
arTabs( 1 ) = "events"
arTabs( 2 ) = "news"
arTabs( 3 ) = "photos"
arTabs( 4 ) = "users"
arTabs( 5 ) = "admin"
%>

<div id="navTabs">

<%
dim theClass, thisPage

thisPage = Request.ServerVariables("SCRIPT_NAME")
thisPage = replace( right( thisPage, len( thisPage ) - inStrRev( thisPage, "/" ) ), ".asp", "" )

for i = 0 to uBound( arTabs)

if thisPage = arTabs(i) or left( thisPage, len( arTabs(i) ) ) = arTabs(i)

then
theClass = "on"

else
theClass = "off"

end if

response.Write("<div class=""tab" & theClass & """ onclick=""javascript:window.location='" & arTabs(i) & ".asp'"">")

Response.Write("<img src=""" & arTabs(i) & ".gif"" align=""absmiddle"" />&nbsp;")

Response.Write( replace( arTabs(i), "_", " " ) & "</div>" & vbCrLf )

next

%>
</div>


DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus
STYLE SHEETS ARTICLES

- CSS Combinators: Working with Child Combinat...
- CSS Combinators: Using General Siblings
- Intro to CSS Combinators
- CSS Semicircles and Web Page Headers
- Drawing Circular Shapes with CSS3 and Border...
- More CSS Pagination Link Templates
- CSS Pagination Links
- Animated CSS3 Image Gallery: Advanced Transi...
- CSS3 Animated Image Gallery: Transitions
- CSS3 Properties: Fixed Heights with box-sizi...
- CSS3 Properties: Altering Strokes and 3D Eff...
- CSS3 Properties: Text-Stroke
- CSS3 Transitions: Width and Height Properties
- Creating a Drop Down Menu in CSS3
- Intro to CSS Transitions

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 1 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials