横向和纵向的下拉菜单第一种实现办法及显示效果

by 清泉 7. 九月 2008 07:54

转自官方引用网站http://www.dynamicdrive.com/dynamicindex1/droptabmenu.htm.
Drop Down Tabs (5种样式)

Drop Down Tabs是一个横向的CSS 选项卡菜单, 每个选项卡都支持二级下拉菜单.
提供了5种下拉菜单显示效果,自己修改CSS文件可以控制下拉菜单显示为别的样式.
这种下拉菜单不会导致下拉菜单偏移.建议使用.

dropdowntabs.zip (20.26 kb)

下面是官方的使用说明:
注下载的附件里面有官方下拉菜单显示效果的演示

Directions

To get Drop Down Tabs, simply download "dropdowntabs.zip", which contains all the files that make up this menu and its accompanying 5 styles. For your reference, some files included within the zip are shown below:

Customization

Setting up and customizing Drop Down Tabs is very simple, as the entire menu consist of regular HTML and styled using CSS. Logically it makes sense to think of the menu in the following three parts:

1) HTML for the menu tabs:

<div id="bluemenu" class="bluetabs">
<ul>
<li><a href="http://www.dynamicdrive.com">Home</a></li>
<li><a href="http://www.dynamicdrive.com/style/" rel="dropmenu1">CSS</a></li>
<li><a href="http://www.dynamicdrive.com/resources/" rel="dropmenu2">Partners</a></li>
<li><a href="http://tools.dynamicdrive.com">Tools</a></li>
</ul>
</div>

As you can see, the menu tabs is simply an ordinary HTML list wrapped inside a DIV. Give this DIV a unique ID to be used to identify it on the page. The arbitrary class attribute provides the desired style for the tabs. Now, to specify that a particular tab carry a drop down menu (shown when mouse rolls over tab), just insert the code rel="unique_id" inside its <a> element, where "unique_id" is the ID of the drop down menu DIV on the page to show (see below). Tabs that don't carry a "rel" attribute will simple be single level in nature.

2) HTML for drop down menu(s):

The drop down menus associated with the desired tabs above are defined as individual DIV tags on the page. For example:

Notice how each DIV carries an arbitrary but unique ID attribute that matches up with the value of the "rel" attribute inside the tab it is to be associated with. The CSS class name is just there to provide styling, and can be modified/ removed as desired.

3) Script to call following the HTML for both of the above to initialize a Tab Menu instance:

Finally, with both parts of a Drop Down Tabs defined, you should call the following script to initialize it on the page:

<script type="text/javascript">
//SYNTAX: tabdropdown.init("menu_id", [integer OR "auto"])
tabdropdown.init("bluemenu", 0)
</script>

The first parameter (highlighted in red) should be the ID of the Menu Tab to initialize once the page has fully loaded. The second parameter is optional, and lets you set which tab should be selected by default- enter either an integer (0=1st tab, 1=2nd tab etc), or "auto" to have the script try to automatically select the tab that matches the current page's URL *. And that's it!

* Note that the "auto" select tab feature mentioned above is rudimentary and isn't meant to replace directly selecting or using server side scripting to identify which tab corresponds to the current page. It won't account for all possibilities where two URLs are the same. Use it as a convenience and fallback plan!

Tags: , , ,

JS相关技术

添加评论



(将显示你的Gravatar头像)  

biuquote
微笑得意调皮害羞酷大笑惊讶发呆喜欢可怜尴尬闭嘴噘嘴皱眉伤心抓狂呕吐坏笑漫骂发怒
Loading



Supidea.com 晨飞的梦 @ All Rights Reserved. Powered by BlogYi.NET ver:1.8.0.0. 苏ICP备09011404号

关于博主

kamau
抱着美好的理想背井离乡,这酸甜苦辣只能默默忍受。既然选择了路,就得风雨兼程……

Calendar

<<  二月 2012  >>
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

在日历中查看文章

最近的评论

Comment RSS

声明

      本博所发一切破解相关附件只作学习研究交流之用,严禁用于商业用途,请在下载24小时内删除。
      本博所有网友评论不代表本博立场,版权归其作者所有。

© Copyright 2009