CSS菜单实现

只含一层的菜单

<nav class="list1">
        <ul>
            <li><a href="#">a</a></li>
            <li><a href="#">b</a></li>
            <li><a href="#">c</a></li>
            <li><a href="#">d</a></li>
            <li><a href="#">e</a></li>
        </ul>
    </nav>

一层纵向菜单

li {list-style:none;}(默认圆点不美观)
    列表项之间设置border
    a {text-textdecoration:none;}(默认下划线不美观)
    a:hover也要重新设置
    a {display:block;}把a的区域扩充到父元素

一层横向菜单

ul {overflow:hidden;}(内容一多溢出就不可见了)
    li {float:left;}
    a {display:block;}扩充点击区域至整个父元素

多层嵌套的菜单

<nav class="multi_drop_menu">
            <ul>
                <li><a href="#">1</a></li>
                <li><a href="#">1</a></li>
                <li><a href="#">1</a></li>
                <li><a href="#">1</a>
                    <ul>
                        <li><a href="#">2</a></li>
                        <li><a href="#">2</a></li>
                        <li><a href="#">2</a>
                            <ul>
                                <li><a href="#">3</a></li>
                                <li><a href="#">3</a></li>
                                <li><a href="#">3</a></li>
                                <li><a href="#">3</a></li>
                            </ul>
                        </li>
                        <li><a href="#">2</a></li>
                    </ul>
                </li>
            </ul>
    </nav>

多层嵌套下拉菜单

.multi_drop_menu * {
                margin:0;
                padding:0;
                }/*减少原来的内外边距对布局的影响*/
            .multi_drop_menu {
                font:1em helvetica, arial,/*微软的无衬线字体*/ sans-serif;/*无衬线字体*/
            }
            .multi_drop_menu a {
                display:block;/*链接区域扩充到整个容器*/
                color:#555;
                background-color:#eee;
                padding:.2em 1em;/*1em相当于body的font-size大小,默认情况下为16px,当然可以修改*/
                border-width:3px;
                border-color:transparent;
            }
            .multi_drop_menu a:hover {
                color:#fff;
                background-color:#aaa;
            }
            .multi_drop_menu a:active {
                color:#ccc;
                background:#fff;/*背景相关的都能写到background里面来*/
            }

.multi_drop_menu ul {
                float:left;
            }
            .multi_drop_menu li {
                float:left;
                position:relative;/*给子元素的absolute定位提供定位上下文*/
                list-style:none;
            }
            .multi_drop_menu li:last-child a {
                border-right-style:none;
            }
            .multi_drop_menu li a {
                display:block;
                border-right-style:solid;
                background-clip:padding-box;/*选定背景显示的盒子区域*/
                text-decoration:none;
            }

.multi_drop_menu li ul {
                width:9em;
                display:none;/*默认不显示,hover时显示*/
                position:absolute;
                left:0;
                top:100%;
            }
            .multi_drop_menu li:hover > ul {
                display:block;
            }/*>左边的只能是父元素*/
            .multi_drop_menu li li {
                float:none;
            }
            .multi_drop_menu li li a {
                border-right-style:none;
                border-top-style:solid;
            }
            .multi_drop_menu li li ul {
                display:none;
            }

.multi_drop_menu li li ul {
                position:absolute;
                left:100%;
                top:0;
            }

.multi_drop_menu.vertical li {
                float:none;
            }
            .multi_drop_menu.vertical li ul {
                left:100%;
                top:0;
            }

时间: 2024-10-12 03:21:04

CSS菜单实现的相关文章

简单的css 菜单

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><style>.sub-nav{    position: relative;    border-bottom: 1px solid #E3E6EA;  

支持多种浏览器的纯css下拉菜单

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312

纯HTML+CSS带说明的黄色导航菜单

HoverTree带说明的CSS菜单:纯HTML+CSS结构链接带说明的黄色导航 在线体验效果:http://hovertree.com/texiao/css/1.htm 代码如下,保存到HTML文件可以看到效果: <!DOCTYPE html > <html > <head> <title>HoverTree带说明的CSS菜单-hovertree.com</title><base target="_blank" /&g

纯CSS实现二级下拉导航菜单

这是一款纯CSS菜单,二级下拉导航效果,是最简洁的CSS导航菜单,兼容性也很棒,IE7/8.火狐等都支持,而且它还是学习CSS菜单编写的典型教程,让你学会很多CSS技巧. 运行效果截图如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xm

纯CSS下拉导航菜单

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" target="_blank">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>

js+css实现简单下拉菜单

<head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>css菜单演示</title> <style type="text/css"> <!-- *{margin:0;padding:0;border:0;} body { font-family: arial, 宋体,

css技术和实例

今天,我为大家收集精选了30个使用纯CSS完成的强大实践的优秀CSS技术和实例,您将在这里发现很多与众不同的技术,比如:图片集.阴影效果.可扩展按钮.菜单等-这些实例都是使用纯CSS和HTML实现的. 单击每个实例的标题可以被转向到该技术实例的相关教程或说明页面,单击每个实例的图片截图可以直接跳转到相应实例的Demo页面. 1.Hoverbox 图片集 一个纯净的基于CSS的图片集,鼠标悬停缩略图就会显示放大效果. 2.高级CSS菜单 一款很有创意且复杂的CSS导航方案. 3.滑动影集 手风琴效

css3圆角阴影菜单有关的文章

[导航菜单特效]最简洁的纯CSS菜单,二级下拉导航 => http://www.q3060.com/list3/list122/22516.html [导航菜单特效]加入了jQuery,二级菜单就有味道了 => http://www.q3060.com/list3/list122/22515.html [导航菜单特效]slideDown和slideUp做手风琴 => http://www.q3060.com/list3/list122/22514.html [导航菜单特效]ul,li结构

精选30个优秀的CSS技术和实例

精选30个优秀的CSS技术和实例 投递人 墙头草 发布于 2008-12-06 20:57 评论(97) 有17487人阅读 原文链接 [收藏] ? ? 今天,我为大家收集精选了30个使用纯CSS完成的强大实践的优秀CSS技术和实例,您将在这里发现很多与众不同的技术,比如:图片集.阴影效果.可扩展按钮.菜单等-这些实例都是使用纯CSS和HTML实现的. 单击每个实例的标题可以被转向到该技术实例的相关教程或说明页面,单击每个实例的图片截图可以直接跳转到相应实例的Demo页面. 1.Hoverbox