编写纯 CSS 弹出菜单的原理及实现 By shawl.qiu
刘欢组,汉威大厦地址,东风本田论坛
-
编写纯 css 弹出菜单的原理及实现 by shawl.qiu
摘要:
本文介绍了使用 css 编写适用于 opera, firefox, ie 的多风格弹出菜单
说明:
编写 css 弹出菜单的要点不外乎当鼠标移到目标上时, 显示出隐藏的标签.
要隐藏的标签使用 display:none; 属性进行隐藏.
触发显示隐藏标签主要使用 :hover 属性, 并用 display:block; 显示隐藏的标签.
但由于浏览器对 css 的支持并非一致.
对于 opera 或者 firefox, 我们可以编写出纯 css 菜单, 他们支持任何标签的 :hover 属性.
而对于 ie 浏览器, :hover 只对 a 标签起作用, 但我们可以使用脚本的 onmouseover, onmouseout 模拟出其他标签的 :hover 属性.
因此编写适用于 ie 的 css 弹出菜单必须使用到少许的脚本.
目录:
1. 编写直排右侧弹出的 css 菜单.
1.1 真正的基于 opera, firefox 纯 css 弹出菜单
1.2 兼容 ie, opera, firefox 的 css 弹出菜单(脚本实现)
2. 编写横排底部弹出的 css 菜单.
2.1 真正的基于 opera, firefox 纯 css 弹出菜单
2.2 兼容 ie, opera, firefox 的 css 弹出菜单(脚本实现)
3. 结论
4. 预览
shawl.qiu
2006-10-01
1. 编写直排右侧弹出的 css 菜单.
1.1 真正的基于 opera, firefox 纯 css 弹出菜单
linenum
- <!doctype html public "-//w3c//dtd html 4.01 transitional//en"
- " ">
- <html>
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8">
- <title>untitled document</title>
- <style type="text/css">
- /*<![cdata[*/ /* shawl.qiu pure css popup menu demo */
- body{ margin:0px auto; width:768px; /* 定义页面居中显示,*/}
- *{text-decoration:none!important; /* 定义所有链接不显示下划线 */}
- .pmverticalrightout{background-color:#fff!important; /* 定义主菜单域背景色 */}
- .pmverticalrightout .level{ /* 定义一级类别属性 */
- width:120px; /* 宽度 */
- height:17; /* 高度 */
- position:relative; /* 显示位置为相对位置 */
- display:block; /* 以块模式显示 */
- background-color:#d8d8d8; /* 背景色 */
- padding:0px 2px; /* 文字内补丁间隔 */
- margin:0px 0px 1px 0px; /* 菜单外补丁间隔 */
- }
- .pmverticalrightout .level:hover { /* 当鼠标划过一级菜单时 */
- background-color:#6633ff; /* 背景色 */
- color:#ffffff; /* 文字颜色 */
- }
- .pmverticalrightout .level_{display:none; /* 默认隐藏二级类别 */}
-
- .pmverticalrightout .level:hover .level_ { /* 鼠标划过时触发显示二级类别 */
- display:block; /* 以块显示 */
- left:124px; /* 相对于一级类别显示的位置 */
- width:120px; /* 宽度 */
- height:auto; /* 高度 */
- top:0px; /* 相对于一级类别所在位置的顶端 */
- background-color:#efefef; /* 定义背景色 */
- position:absolute; /* 位置为绝对位置 */
- }
- .pmverticalrightout .level:hover .level_ .level_title {
- /* 定义二级类别标题样式 */
- font-weight:bold; /* 字体加粗 */
- background-color:#a7adfe; /* 背景色 */
- color:white; /* 文字颜色 */
- }
- .pmverticalrightout .level:hover .level_ a:hover {
- /* 定义二级类别链接显示样式 */
- background-color:#f83658; /* 背景色 */
- color:white; /* 文字颜色 */
- }
- .pmverticalrightout .level_ * {
- /* 定义所有二级类别通用属性 */
- display:block; /* 以块显示 */
- color:black; /* 文字颜色 */
- padding:0px 2px; /* 内补丁间隔 */
- }
- /*]]>*/
- </style>
- </head>
- <body>
- <p/><p/><p/><p/><p/>
- <div class="pmverticalrightout" id="pmverticalrightout">
- <div class="level">
- <div class="leveltitle">level</div>
- <div class="level_">
- <div class="level_title">level_ title</div>
- <a href="?cat=level&id=1">level_ title 1</a>
- <a href="?cat=level&id=2">level_ title 2</a>
- <a href="?cat=level&id=3">level_ title 3</a>
- <a href="?cat=level&id=4">level_ title 4</a>
- <a href="?cat=level&id=5">level_ title 5</a>
- </div>
- </div>
- <div class="level">
- <div class="leveltitle">level 1</div>
- <div class="level_">
- <div class="level_title">level_ title</div>
- <a href="?cat=level_1&id=1">level_ title 1</a>
- <a href="?cat=level_1&id=2">level_ title 2</a>
- <a href="?cat=level_1&id=3">level_ title 3</a>
- <a href="?cat=level_1&id=4">level_ title 4</a>
- <a href="?cat=level_1&id=5">level_ title 5</a>
- </div>
- </div>
- <div class="level">
- <div class="leveltitle">level 2</div>
- <div class="level_">
- <div class="level_title">level_ title</div>
- <a href="?cat=level_2&id=1">level_ title 1</a>
- <a href="?cat=level_2&id=2">level_ title 2</a>
- <a href="?cat=level_2&id=3">level_ title 3</a>
- <a href="?cat=level_2&id=4">level_ title 4</a>
- <a href="?cat=level_2&id=5">level_ title 5</a>
- </div>
- </div>
- <div class="level">
- <div class="leveltitle">level 3</div>
- <div class="level_">
- <div class="level_title">level_ title</div>
- <a href="?cat=level_3&id=1">level_ title 1</a>
- <a href="?cat=level_3&id=2">level_ title 2</a>
- <a href="?cat=level_3&id=3">level_ title 3</a>
- <a href="?cat=level_3&id=4">level_ title 4</a>
- <a href="?cat=level_3&id=5">level_ title 5</a>
- </div>
- </div>
- <div class="level">
- <div class="leveltitle">level 4</div>
- <div class="level_">
- <div class="level_title">level_ title</div>
- <a href="?cat=level_4&id=1">level_ title 1</a>
- <a href="?cat=level_4&id=2">level_ title 2</a>
- <a href="?cat=level_4&id=3">level_ title 3</a>
- <a href="?cat=level_4&id=4">level_ title 4</a>
- <a href="?cat=level_4&id=5">level_ title 5</a>
- </div>
- </div>
- </div>
- </body>
- </html>
1.2 兼容 ie, opera, firefox 的 css 弹出菜单(脚本实现)
linenum
- <!doctype html public "-//w3c//dtd html 4.01 transitional//en"
- " ">
- <html>
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8">
- <title>untitled document</title>
- <style type="text/css">
- /*<![cdata[*/ /* shawl.qiu pure css popup menu demo */
- body{ margin:0px auto; width:768px; /* 定义页面居中显示,*/}
- *{text-decoration:none!important; /* 定义所有链接不显示下划线 */}
- /* ------------------- start 针对 opera, firefox 的 css 弹出菜单 -------------------*/
- .pmverticalrightout{background-color:#fff!important; /* 定义主菜单域背景色 */}
- .pmverticalrightout .level{ /* 定义一级类别属性 */
- width:120px; /* 宽度 */
- height:17; /* 高度 */
- position:relative; /* 显示位置为相对位置 */
- display:block; /* 以块模式显示 */
- background-color:#d8d8d8; /* 背景色 */
- padding:0px 2px; /* 文字内补丁间隔 */
- margin:0px 0px 1px 0px; /* 菜单外补丁间隔 */
- }
- .pmverticalrightout .level:hover { /* 当鼠标划过一级菜单时 */
- background-color:#6633ff; /* 背景色 */
- color:#ffffff; /* 文字颜色 */
- }
- .pmverticalrightout .level_{display:none; /* 默认隐藏二级类别 */}
-
- .pmverticalrightout .level:hover .level_ { /* 鼠标划过时触发显示二级类别 */
- display:block; /* 以块显示 */
- left:124px; /* 相对于一级类别显示的位置 */
- width:120px; /* 宽度 */
- height:auto; /* 高度 */
- top:0px; /* 相对于一级类别所在位置的顶端 */
- background-color:#efefef; /* 定义背景色 */
- position:absolute; /* 位置为绝对位置 */
- }
- .pmverticalrightout .level:hover .level_ .level_title {
- /* 定义二级类别标题样式 */
- font-weight:bold; /* 字体加粗 */
- background-color:#a7adfe; /* 背景色 */
- color:white; /* 文字颜色 */
- }
- .pmverticalrightout .level:hover .level_ a:hover {
- /* 定义二级类别链接显示样式 */
- background-color:#f83658; /* 背景色 */
- color:white; /* 文字颜色 */
- }
- .pmverticalrightout .level:hover .level_ * {
- /* 定义所有二级类别通用属性 */
- display:block; /* 以块显示 */
- color:black; /* 文字颜色 */
- padding:0px 2px; /* 内补丁间隔 */
- }
- /* ------------------- end 针对 opera, firefox 的 css 弹出菜单 -------------------*/
-
- /* ------------------- start 针对 ie 的 css 弹出菜单 -------------------*/
- .levelie{ /* 定义一级类别属性 */
- width:120px; /* 宽度 */
- height:17; /* 高度 */
- position:relative; /* 显示位置为相对位置 */
- display:block; /* 以块模式显示 */
- background-color:#d8d8d8; /* 背景色 */
- padding:0px 2px; /* 文字内补丁间隔 */
- margin:0px 0px 1px 0px; /* 菜单外补丁间隔 */
- }
- .levelie .level_ { /* 鼠标划过时触发显示二级类别 */
- display:block; /* 以块显示 */
- left:124px; /* 相对于一级类别显示的位置 */
- width:120px; /* 宽度 */
- height:auto; /* 高度 */
- top:0px; /* 相对于一级类别所在位置的顶端 */
- background-color:#efefef; /* 定义背景色 */
- position:absolute; /* 位置为绝对位置 */
- }
- .levelie .level_ .level_title {
- /* 定义二级类别标题样式 */
- font-weight:bold; /* 字体加粗 */
- background-color:#a7adfe; /* 背景色 */
- color:white; /* 文字颜色 */
- }
- .levelie .level_ a:hover {
- /* 定义二级类别链接显示样式 */
- background-color:#f83658; /* 背景色 */
- color:white; /* 文字颜色 */
- }
- .levelie .level_ * {
- /* 定义所有二级类别通用属性 */
- display:block; /* 以块显示 */
- color:black; /* 文字颜色 */
- padding:0px 2px; /* 内补丁间隔 */
- }
- /* ------------------- end 针对 ie 的 css 弹出菜单 -------------------*/
- /*]]>*/
- </style>
- <script type="text/javascript">
- //<![cdata[
- if (navigator.appname=="microsoft internet explorer") {
- function fpmverticalrightout() {
- var getitem = document.getelementbyid("pmverticalrightout").getelementsbytagname("div");
- for (var i=0; i<getitem.length; i++) {
- getitem[i].onmouseover=function() {
- if( this.classname=="level"){
- this.classname="levelie";
- }
- }
- getitem[i].onmouseout=function() {
- if( this.classname=="levelie"){
- this.classname="level";
- }
- }//css popup menu script by shawl.qiu
- }
- }
- window.onload=fpmverticalrightout;
- }
- //]]>
- </script>
- </head>
- <body>
- <p/><p/><p/><p/><p/>
- <div class="pmverticalrightout" id="pmverticalrightout">
- <div class="level">
- <div class="leveltitle">level</div>
- <div class="level_">
- <div class="level_title">level_ title</div>
- <a href="?cat=level&id=1">level_ title 1</a>
- <a href="?cat=level&id=2">level_ title 2</a>
- <a href="?cat=level&id=3">level_ title 3</a>
- <a href="?cat=level&id=4">level_ title 4</a>
- <a href="?cat=level&id=5">level_ title 5</a>
- </div>
- </div>
- <div class="level">
- <div class="leveltitle">level 1</div>
- <div class="level_">
- <div class="level_title">level_ title</div>
- <a href="?cat=level_1&id=1">level_ title 1</a>
- <a href="?cat=level_1&id=2">level_ title 2</a>
- <a href="?cat=level_1&id=3">level_ title 3</a>
- <a href="?cat=level_1&id=4">level_ title 4</a>
- <a href="?cat=level_1&id=5">level_ title 5</a>
- </div>
- </div>
- <div class="level">
- <div class="leveltitle">level 2</div>
- <div class="level_">
- <div class="level_title">level_ title</div>
- <a href="?cat=level_2&id=1">level_ title 1</a>
- <a href="?cat=level_2&id=2">level_ title 2</a>
- <a href="?cat=level_2&id=3">level_ title 3</a>
- <a href="?cat=level_2&id=4">level_ title 4</a>
- <a href="?cat=level_2&id=5">level_ title 5</a>
- </div>
- </div>
- <div class="level">
- <div class="leveltitle">level 3</div>
- <div class="level_">
- <div class="level_title">level_ title</div>
- <a href="?cat=level_3&id=1">level_ title 1</a>
- <a href="?cat=level_3&id=2">level_ title 2</a>
- <a href="?cat=level_3&id=3">level_ title 3</a>
- <a href="?cat=level_3&id=4">level_ title 4</a>
- <a href="?cat=level_3&id=5">level_ title 5</a>
- </div>
- </div>
- <div class="level">
- <div class="leveltitle">level 4</div>
- <div class="level_">
- <div class="level_title">level_ title</div>
- <a href="?cat=level_4&id=1">level_ title 1</a>
- <a href="?cat=level_4&id=2">level_ title 2</a>
- <a href="?cat=level_4&id=3">level_ title 3</a>
- <a href="?cat=level_4&id=4">level_ title 4</a>
- <a href="?cat=level_4&id=5">level_ title 5</a>
- </div>
- </div>
- </div>
- </body>
- </html>
2. 编写横排底部弹出的 css 菜单.
2.1 真正的基于 opera, firefox 纯 css 弹出菜单
linenum
- <!doctype html public "-//w3c//dtd html 4.01 transitional//en"
- " ">
- <html>
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8">
- <title>untitled document</title>
- <style type="text/css">
- /*<![cdata[*/ /* shawl.qiu pure css popup menu demo */
- body{ margin:0px auto; width:768px; /* 定义页面居中显示,*/}
- *{text-decoration:none!important; /* 定义所有链接不显示下划线 */}
- .pmhorizontalbottomout{background-color:#fff!important; /* 定义主菜单域背景色 */}
- .pmhorizontalbottomout .level{ /* 定义一级类别属性 */
- width:120px; /* 宽度 */
- height:17; /* 高度 */
- position:relative; /* 显示位置为相对位置 */
- display:block; /* 以块模式显示 */
- background-color:#d8d8d8; /* 背景色 */
- padding:0px 2px; /* 文字内补丁间隔 */
- margin:0px 1px 0px 0px; /* 菜单外补丁间隔 */
- float:left;
- }
- .pmhorizontalbottomout .level:hover { /* 当鼠标划过一级菜单时 */
- background-color:#6633ff; /* 背景色 */
- color:#ffffff; /* 文字颜色 */
- }
- .pmhorizontalbottomout .level_{display:none; /* 默认隐藏二级类别 */}
-
- .pmhorizontalbottomout .level:hover .level_ { /* 鼠标划过时触发显示二级类别 */
- display:block; /* 以块显示 */
- width:124px; /* 宽度 */
- height:auto; /* 高度 */
- margin:0px -2px 0px -2px; /* 外补丁 */
- background-color:#efefef; /* 定义背景色 */
- position:absolute; /* 位置为绝对位置 */
- }
- .pmhorizontalbottomout .level:hover .level_ .level_title {
- /* 定义二级类别标题样式 */
- font-weight:bold; /* 字体加粗 */
- background-color:#a7adfe; /* 背景色 */
- color:white; /* 文字颜色 */
- }
- .pmhorizontalbottomout .level:hover .level_ a:hover {
- /* 定义二级类别链接显示样式 */
- background-color:#f83658; /* 背景色 */
- color:white; /* 文字颜色 */
- }
- .pmhorizontalbottomout .level_ * {
- /* 定义所有二级类别通用属性 */
- display:block; /* 以块显示 */
- color:black; /* 文字颜色 */
- padding:0px 2px; /* 内补丁间隔 */
- }
- /*]]>*/
- </style>
- </head>
- <body>
- <p/><p/><p/><p/><p/>
- <div class="pmhorizontalbottomout" id="pmhorizontalbottomout">
- <div class="level">
- <div class="leveltitle">level</div>
- <div class="level_">
- <div class="level_title">level_ title</div>
- <a href="?cat=level&id=1">level_ title 1</a>
- <a href="?cat=level&id=2">level_ title 2</a>
- <a href="?cat=level&id=3">level_ title 3</a>
- <a href="?cat=level&id=4">level_ title 4</a>
- <a href="?cat=level&id=5">level_ title 5</a>
- </div>
- </div>
- <div class="level">
- <div class="leveltitle">level 1</div>
- <div class="level_">
- <div class="level_title">level_ title</div>
- <a href="?cat=level_1&id=1">level_ title 1</a>
- <a href="?cat=level_1&id=2">level_ title 2</a>
- <a href="?cat=level_1&id=3">level_ title 3</a>
- <a href="?cat=level_1&id=4">level_ title 4</a>
- <a href="?cat=level_1&id=5">level_ title 5</a>
- </div>
- </div>
- <div class="level">
- <div class="leveltitle">level 2</div>
- <div class="level_">
- <div class="level_title">level_ title</div>
- <a href="?cat=level_2&id=1">level_ title 1</a>
- <a href="?cat=level_2&id=2">level_ title 2</a>
- <a href="?cat=level_2&id=3">level_ title 3</a>
- <a href="?cat=level_2&id=4">level_ title 4</a>
- <a href="?cat=level_2&id=5">level_ title 5</a>
- </div>
- </div>
- <div class="level">
- <div class="leveltitle">level 3</div>
- <div class="level_">
- <div class="level_title">level_ title</div>
- <a href="?cat=level_3&id=1">level_ title 1</a>
- <a href="?cat=level_3&id=2">level_ title 2</a>
- <a href="?cat=level_3&id=3">level_ title 3</a>
- <a href="?cat=level_3&id=4">level_ title 4</a>
- <a href="?cat=level_3&id=5">level_ title 5</a>
- </div>
- </div>
- <div class="level">
- <div class="leveltitle">level 4</div>
- <div class="level_">
- <div class="level_title">level_ title</div>
- <a href="?cat=level_4&id=1">level_ title 1</a>
- <a href="?cat=level_4&id=2">level_ title 2</a>
- <a href="?cat=level_4&id=3">level_ title 3</a>
- <a href="?cat=level_4&id=4">level_ title 4</a>
- <a href="?cat=level_4&id=5">level_ title 5</a>
- </div>
- </div>
- </div>
- </body>
- </html>
2.2 兼容 ie, opera, firefox 的 css 弹出菜单(脚本实现)
linenum
- <!doctype html public "-//w3c//dtd html 4.01 transitional//en"
- " ">
- <html>
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8">
- <title>untitled document</title>
- <style type="text/css">
- /*<![cdata[*/ /* shawl.qiu pure css popup menu demo */
- body{ margin:0px auto; width:768px; /* 定义页面居中显示,*/}
- *{text-decoration:none!important; /* 定义所有链接不显示下划线 */}
- /* ------------------- start 针对 opera, firefox 的 css 弹出菜单 -------------------*/
- .pmhorizontalbottomout{background-color:#fff!important; /* 定义主菜单域背景色 */}
- .pmhorizontalbottomout .level{ /* 定义一级类别属性 */
- width:120px; /* 宽度 */
- height:17; /* 高度 */
- position:relative; /* 显示位置为相对位置 */
- display:block; /* 以块模式显示 */
- background-color:#d8d8d8; /* 背景色 */
- padding:0px 2px; /* 文字内补丁间隔 */
- margin:0px 1px 0px 0px; /* 菜单外补丁间隔 */
- float:left;
- }
- .pmhorizontalbottomout .level:hover { /* 当鼠标划过一级菜单时 */
- background-color:#6633ff; /* 背景色 */
- color:#ffffff; /* 文字颜色 */
- }
- .pmhorizontalbottomout .level_{display:none; /* 默认隐藏二级类别 */}
-
- .pmhorizontalbottomout .level:hover .level_ { /* 鼠标划过时触发显示二级类别 */
- display:block; /* 以块显示 */
- width:124px; /* 宽度 */
- height:auto; /* 高度 */
- margin:0px -2px 0px -2px; /* 外补丁 */
- background-color:#efefef; /* 定义背景色 */
- position:absolute; /* 位置为绝对位置 */
- }
- .pmhorizontalbottomout .level:hover .level_ .level_title {
- /* 定义二级类别标题样式 */
- font-weight:bold; /* 字体加粗 */
- background-color:#a7adfe; /* 背景色 */
- color:white; /* 文字颜色 */
- }
- .pmhorizontalbottomout .level:hover .level_ a:hover {
- /* 定义二级类别链接显示样式 */
- background-color:#f83658; /* 背景色 */
- color:white; /* 文字颜色 */
- }
- .pmhorizontalbottomout .level_ * {
- /* 定义所有二级类别通用属性 */
- display:block; /* 以块显示 */
- color:black; /* 文字颜色 */
- padding:0px 2px; /* 内补丁间隔 */
- }
- /* ------------------- end 针对 opera, firefox 的 css 弹出菜单 -------------------*/
-
- /* ------------------- start 针对 ie 的 css 弹出菜单 -------------------*/
- .levelie{ /* 定义一级类别属性 */
- width:120px; /* 宽度 */
- height:17; /* 高度 */
- position:relative; /* 显示位置为相对位置 */
- display:block; /* 以块模式显示 */
- background-color:#d8d8d8; /* 背景色 */
- padding:0px 2px; /* 文字内补丁间隔 */
- margin:0px 1px 0px 0px; /* 菜单外补丁间隔 */
- float:left;
- }
- .levelie { /* 当鼠标划过一级菜单时 */
- background-color:#6633ff; /* 背景色 */
- color:#ffffff; /* 文字颜色 */
- }
- .levelie .level_ { /* 鼠标划过时触发显示二级类别 */
- display:block; /* 以块显示 */
- width:124px; /* 宽度 */
- height:auto; /* 高度 */
- margin:0px -2px 0px -2px; /* 外补丁 */
- background-color:#efefef; /* 定义背景色 */
- position:absolute; /* 位置为绝对位置 */
- }
- .levelie .level_ .level_title {
- /* 定义二级类别标题样式 */
- font-weight:bold; /* 字体加粗 */
- background-color:#a7adfe; /* 背景色 */
- color:white; /* 文字颜色 */
- }
- .levelie .level_ a:hover {
- /* 定义二级类别链接显示样式 */
- background-color:#f83658; /* 背景色 */
- color:white; /* 文字颜色 */
- }
- .levelie .level_ * {
- /* 定义所有二级类别通用属性 */
- display:block; /* 以块显示 */
- color:black; /* 文字颜色 */
- padding:0px 2px; /* 内补丁间隔 */
- }
- /* ------------------- end 针对 ie 的 css 弹出菜单 -------------------*/
- /*]]>*/
- </style>
- <script type="text/javascript">
- //<![cdata[
- if (navigator.appname=="microsoft internet explorer") {
- function fpmhorizontalbottomout() {
- var getitem = document.getelementbyid("pmhorizontalbottomout").getelementsbytagname("div");
- for (var i=0; i<getitem.length; i++) {
- getitem[i].onmouseover=function() {
- if( this.classname=="level"){
- this.classname="levelie";
- }
- }
- getitem[i].onmouseout=function() {
- if( this.classname=="levelie"){
- this.classname="level";
- }
- }//css popup menu script by shawl.qiu
- }
- }
- window.onload=fpmhorizontalbottomout;
- }
- //]]>
- </script>
- </head>
- <body>
- <p/><p/><p/><p/><p/>
- <div class="pmhorizontalbottomout" id="pmhorizontalbottomout">
- <div class="level">
- <div class="leveltitle">level</div>
- <div class="level_">
- <div class="level_title">level_ title</div>
- <a href="?cat=level&id=1">level_ title 1</a>
- <a href="?cat=level&id=2">level_ title 2</a>
- <a href="?cat=level&id=3">level_ title 3</a>
- <a href="?cat=level&id=4">level_ title 4</a>
- <a href="?cat=level&id=5">level_ title 5</a>
- </div>
- </div>
- <div class="level">
- <div class="leveltitle">level 1</div>
- <div class="level_">
- <div class="level_title">level_ title</div>
- <a href="?cat=level_1&id=1">level_ title 1</a>
- <a href="?cat=level_1&id=2">level_ title 2</a>
- <a href="?cat=level_1&id=3">level_ title 3</a>
- <a href="?cat=level_1&id=4">level_ title 4</a>
- <a href="?cat=level_1&id=5">level_ title 5</a>
- </div>
- </div>
- <div class="level">
- <div class="leveltitle">level 2</div>
- <div class="level_">
- <div class="level_title">level_ title</div>
- <a href="?cat=level_2&id=1">level_ title 1</a>
- <a href="?cat=level_2&id=2">level_ title 2</a>
- <a href="?cat=level_2&id=3">level_ title 3</a>
- <a href="?cat=level_2&id=4">level_ title 4</a>
- <a href="?cat=level_2&id=5">level_ title 5</a>
- </div>
- </div>
- <div class="level">
- <div class="leveltitle">level 3</div>
- <div class="level_">
- <div class="level_title">level_ title</div>
- <a href="?cat=level_3&id=1">level_ title 1</a>
- <a href="?cat=level_3&id=2">level_ title 2</a>
- <a href="?cat=level_3&id=3">level_ title 3</a>
- <a href="?cat=level_3&id=4">level_ title 4</a>
- <a href="?cat=level_3&id=5">level_ title 5</a>
- </div>
- </div>
- <div class="level">
- <div class="leveltitle">level 4</div>
- <div class="level_">
- <div class="level_title">level_ title</div>
- <a href="?cat=level_4&id=1">level_ title 1</a>
- <a href="?cat=level_4&id=2">level_ title 2</a>
- <a href="?cat=level_4&id=3">level_ title 3</a>
- <a href="?cat=level_4&id=4">level_ title 4</a>
- <a href="?cat=level_4&id=5">level_ title 5</a>
- </div>
- </div>
- </div>
- </body>
- </html>
3. 结论
以上例子可以看出, 如果已经编写出一个可用的css弹出菜单例子, 那要编写出弹出位置在其他地方的 css 弹出菜单的话, 只须小小修改一下就 ok.
4. 预览
4.1 1.2 兼容 ie, opera, firefox 的 css 弹出菜单(脚本实现) 的预览
-
4.2 2.2 兼容 ie, opera, firefox 的 css 弹出菜单(脚本实现) 的预览
-
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!!
点击进行留言回复
相关文章:
-
-
-
详解CSS3新增的背景属性
CSS3新增属性:background-clip ,background-origin , background-size,本文给大家分享CSS3新增的背景属性...
[阅读全文]
-
-
-
CSS3 旋转立方体问题详解
这篇文章主要介绍了CSS3 旋转立方体问题详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学...
[阅读全文]
-
Grid 宫格常用布局的实现
这篇文章主要介绍了Grid 宫格常用布局的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学...
[阅读全文]
-
-
-
CSS3实现网站商品展示效果图
这篇文章主要介绍了CSS3实现网站商品展示效果图,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习...
[阅读全文]
-
网友评论