Should tabs all be the same width, or should they vary based on their content? This library allows the tab widths to vary.
Examples
Tab 1 page contents go here
Tab 2 page contents go here
When the mouse hovers over the tab, a longer description is displayed. |
Tabset B 1 page contents go here
This width is narrower than the other panel
Tabset B 2 page contents go here
When the mouse hovers over the tab, a longer description is displayed. |
Usage
<script src="js/mcUITabs.js" type="text/javascript"></script> <link href="js/mcUITabs.css" type="text/css" rel="stylesheet" > |
Tab Button
<input type="button" id="tab_unique_name" class="mcUITab_Button" value="This is displayed" title="This is an optional long descriptive phrase" xtype=hidden > |
<input type="button" id="tab_" class="mcUITab_Button" value="" xtitle="" xtype=hidden > |
If I want to hide a tab, I just uncomment the type property. I normally do this if I want to distribute a "work in process" and not have broken tabs.
Using this technique (ie, including the non-functional properties), I don't have to look up commands for fairly common tasks.
Tab Page
<div id=tab_xx_page > Tab page contents go here </div id=end_tab_xx_page> <!-- ****************************************************************************** --> |
Each page may support an onDisplay event called (if present) when the tab is clicked. This feature is not compatible with tearoff tabs (where each tab can be displayed in its own independent window).
tab_page.onDisplay = someFunction; function someFunction(tab_button.id) {} |
Tab Page Container
The Tab Page Container is simply a div wrapper with a class of mcUITabPanel and a unique ID (for setting the size). - all the individual tab pages are placed inside it.
Note: | The class name - mcUITabPanel - is used to configure the Tab Control and must not be changed. |
Tab 1 page contents go here
Tab 2 page contents go here
When the mouse hovers over the tab, a longer description is displayed. |
The long strings of asterisks really help when editing.
At the top of the file, you should include a style definition to set the size - both height and width - of the panel (container div). Since there may be multiple tab panels in an application, this style should refer to a unique ID (the style name starts with a pound sign - #).
#mcUITabPanelUniqueID{ width :300px; /* just a default */ height:100px; } |
Multiple Tab Panels
Styles
.mcUITab_Buttons { word-spacing: -4px; /* better than float:left */ height: 20px; /* button default height */ } .mcUITab_Button { background-color:#f4f1ed; /* lighter than the panel */ border-bottom-style:none; } .mcUITab_Button:hover { background-color:#e4e1ce; /* darker than normal */ } .mcUITab_Button.mcUITab_Button_Active{ background-color: #ece9d8; /* same as the panel */ border-bottom-color: #ece9d8; border-bottom-style: solid; border-bottom-width: 3px; border-left-color: #fbfbfb; border-top-color: #fbfbfb; } .mcUITabPanel, .mcUIRaisedPanel{ border-style: solid; padding: 5px; background-color:#ece9d8; /* the default is too blue */ border-width: 2px; border-color: #fbfbfb #aca899 #aca899 #fbfbfb ; } |
The .mcUITabPanel, .mcUIRaisedPanel style is identical in both mcUITools.css and mcUITabs.css.
As discussed above, the individual tab pages are placed inside a fixed size container so that the tab display won't change size each time a different tab is selected.
#mcUITabPanelUniqueID{ width :300px; /* just a default */ height:100px; } |
Two rows of Tabs
These are examples - use the mouse and click the tabs | ||
---|---|---|
Wide - Single row | 2 rows | 2 rows with fix |
Tab 1 page contents go here
Tab 2 page contents go here
Set height so this doesn't happen
Tab 3 page contents go here
Tab 4 page contents go here
|
Tab 1 page contents go here
Tab 2 page contents go here
Set height so this doesn't happen
Tab 3 page contents go here
Tab 4 page contents go here
|
Tab 1 page contents go here
Tab 2 page contents go here
Set height so this doesn't happen
Tab 3 page contents go here
Tab 4 page contents go here
|
Looks good Current tab is obvious | Tabs overlap page content | Acceptable |
This (archived) reference describes another approach - the tabs are table columns (instead of buttons in my example) and use images (gifs) to indicate selected or not.
Author: Robert Clemenzi