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"" /> ")
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. |
|
| · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | | |
|