Go Back   Novahq.net Forum > Computers > Web design and Programming
FAQ Community Calendar Today's Posts Search

Web design and Programming Discuss website creation and other programming topics.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-05-2007, 04:26 AM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,927

CSS Tabs

I needed to create 'tab like' features for a site I am building.. I searched Google high and low for a pre-made script but they were all to complex for such a simple task, so I made my own with the help of snippets from others.

Maybe you'll find it useful , tested in Firefox v1/2, IE v6/7, Opera v9. Seems to work ok. Requires Javascript.

PHP Code:
<html>
<
head>
<
title>CSS Tabs</title>
<
script type="text/javascript">
<!--
function 
css_tabs(divID) {
    
    var 
tab="";
    var 
layers=new Array()
    
layers[0]="tab1"
    
layers[1]="tab2"
    
layers[2]="tab3"

    
for (x in layers) {

        
layer=layers[x];
        
tab="tab_" layer;
        
        if(
layers[x]==divID) {
            
document.getElementById(layer).style.display "block";
            
document.getElementById(tab).className "active";
        } else {
            
document.getElementById(layer).style.display "none";
            
document.getElementById(tab).className "";
        }
    }

}
-->
</
script>

<
style type="text/css">
<!--
#tabs {
    
height23px;
    
border-bottom:1px solid #C6C6C6;
    
margin0;
    
font-size12pt;
    
font-family:Verdana;
    
font-weightbold;
}

#tabs ul {
    
margin0
    
padding0;
}

#tabs li {
    
list-style-typenone;
    
displayinline;
    
margin0
    
padding0;
}
    
#tabs a:link, #tabs a:visited {
    
floatleft;
    
background#F3F3F3;
    
line-height18px;
    
padding2px 10px 2px 10px;
    
margin-right5px;
    
border1px solid #C6C6C6;
    
border-bottom:0px;
    
color#8B8B8B;
    
text-decorationnone;
}

#tabs a:hover, #tabs a:link.active, #tabs a:visited.active {
    
background#FFFFFF;
    
color#000000;
    
text-decorationnone;
}
-->
</
style>
</
head>
<
body>

<
div id="tabs">
    <
ul>
        <
li><a href="javascript:void(0);" onclick="css_tabs('tab1');" id="tab_tab1" class="active">Tab 1</a></li>
        <
li><a href="javascript:void(0);" onclick="css_tabs('tab2');" id="tab_tab2" class="">Tab 2</a></li>
        <
li><a href="javascript:void(0);" onclick="css_tabs('tab3');" id="tab_tab3" class="">Tab 3</a></li>
    </
ul>
</
div>
    
<
div id="tab1" style="display:block">
This is some text in tab #1
</div>
    
    
<
div id="tab2" style="display:none">
This is some text in tab #2
</div>
    

<
div id="tab3" style="display:none">
This is some text in tab #3    
</div>

</
body>
</
html
Download:
Attached Files
File Type: rar tabs.rar (828 Bytes, 25 views)
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Css JonM Gaming Talk 1 08-18-2007 05:06 PM
How do I change tabs and format GÂ~ûrÐêâd ~DW~ phphq.Net Forums 0 03-30-2006 08:53 AM
Css Jason Gaming Talk 17 09-07-2005 09:27 AM
css help VooDoo- Gaming Talk 10 02-02-2005 10:33 PM
.css zabb phphq.Net Forums 2 12-11-2004 04:09 PM


All times are GMT -5. The time now is 11:06 AM.




Powered by vBulletin®