html、css下拉菜单和队列

html、css下拉菜单和队列,css,html,Css,Html,标题{ 背景:#f37124; } #标志{ 边距:0自动;显示:块; } #主导航{ 背景:#f37124; 高度:51px; 文本对齐:居中; 保证金:0自动; 位置:相对位置; 字体:16px塔荷马,无衬线; } #主要的{ 保证金:0自动; 显示:块; } a{ 文字装饰:无; } 导航ul{ 显示:无; } 导航ul li:悬停>ul{ 背景:#f37124; 显示:块; 利润率:10px; } 导航ul{ 背景:#f37124; 列表样式:无; 位置:静态; 显示:块; 填充顶部:1

标题{
背景:#f37124;
}
#标志{
边距:0自动;显示:块;
}
#主导航{
背景:#f37124;
高度:51px;
文本对齐:居中;
保证金:0自动;
位置:相对位置;
字体:16px塔荷马,无衬线;
}
#主要的{
保证金:0自动;
显示:块;
}
a{
文字装饰:无;
}
导航ul{
显示:无;
}
导航ul li:悬停>ul{
背景:#f37124;
显示:块;
利润率:10px;
}
导航ul{
背景:#f37124;
列表样式:无;
位置:静态;
显示:块;
填充顶部:15px;
}
海军ul:之后{
内容:“;
明确:两者皆有;
显示:块;
}
李国荣{
浮动:左;
位置:相对位置;
左:50%;
左边距:10px;
右边距:10px;
}
nav ul li:悬停{
}
nav ul li:悬停a{
}
海军ulli a{
显示:块;
/*填充:25px 40px*/
颜色:#111111;
文字装饰:无;
位置:相对位置;
}
导航ul{
背景:#ffffff;
边界半径:0px;
填充:0px;
位置:绝对位置;
最高:100%;
}
李国宝{
浮动:无;
/*边框顶部:1px实心#6b727c*/
位置:相对位置;
}
海军ulli a{
填充:15px 40px;
}   
导航ulli a:悬停{
背景:#4b545f;
}
导航ul{
位置:绝对;左侧:100%;顶部:0;
}
1.文本居中对齐

我想把文字居中

我想在字符之间保持恒定的宽度

2右下拉菜单

悬停项目ul和下拉服务菜单,但我不能

应该隔开

你肯定出去了

问题是保证金??? 还是填充


我找不到它

要理解你的要求有点困难,但我想你是说你希望主要导航元素的间距相等,以单个空间为中心

试试这个:

    header{
        background: #f37124;
    }

    #logo{

        margin:0 auto; display:block; 
    }

    #nav_main{
        background: #f37124;
        height: 51px;
        text-align: center; 
        margin:0 auto ;
        position:relative; 
        font:16px Tahoma, Sans-serif;
    }

    #main_img{
        margin:0 auto; 
        display:block;
    }
    a{
        text-decoration: none; 
    }




    nav ul ul {
        display: none;
    }

        nav ul li:hover > ul {
            background: #f37124;                
            display: block;
            margin: 10px;


        }




    nav ul {
        background: #f37124;
        list-style: none;
        position: static;
        display: block;
        padding-top: 15px;
    }
        nav ul:after {
            content: ""; 
            clear: both; 
            display: block;
        }


    nav ul li {
        float: left;
        position: relative;
        left: 50%;
        margin-left: 10px;
        margin-right: 10px;
    }
        nav ul li:hover {

        }
            nav ul li:hover a {
                                }

        nav ul li a {
            display: block; 
            /*padding: 25px 40px;*/
            color: #111111; 
            text-decoration: none;
            position: relative;

        }




    nav ul ul {
        background: #ffffff; 
        border-radius: 0px; 
        padding: 0px;
        position: absolute; 
        top: 100%;
    }
        nav ul ul li {
            float: none; 
            /*border-top: 1px solid #6b727c;*/
            position: relative;
        }
            nav ul ul li a {
                padding: 15px 40px;

            }   
                nav ul ul li a:hover {
                    background: #4b545f;
                }

    nav ul ul ul {
        position: absolute; left: 100%; top:0;
    }

</style>
此外,您缺少标记的结束链接:


  • JS Fiddle here:

    我就是这样解决的:

    header
    {
       background: #f37124;
    }
    
    #nav_main{
        background: #f37124;
        height: 51px;
        text-align: center; 
        margin:0 auto ;
        position:relative; 
        font:16px Tahoma, Sans-serif;
    }
    
    
    a{
        text-decoration: none; 
     }
    
    
    nav ul ul {
        display: none;
    }
    
    nav ul li:hover > ul {
       background: #f37124;                
       display: block;
    }
    
    nav ul {
        background: #f37124;
        list-style: none;
        position: relative;
        display: block;
        padding-top: 15px;
    }
    
    nav ul li {
        float: left;
        position: relative;
        width: 20%;
    }
    nav ul li a {
       display: block; 
       color: #111111; 
       text-decoration: none;
       position: relative;
    }
    
    nav ul ul {
        background: #ffffff; 
        border-radius: 0px; 
        padding: 0px;
        position: absolute; 
        top: 100%;
    }
    
    nav ul ul li {
        float: none; 
        position: relative;
        width: auto;
    }
    
    nav ul ul li a {
         padding: 15px 40px;
    }   
    
    nav ul ul li a:hover {
        background: #4b545f;
    }
    
    
    标题{
    背景:#f37124;
    }
    #标志{
    边距:0自动;显示:块;
    }
    #主导航{
    背景:#f37124;高度:51px;文本对齐:居中;边距:0自动;
    位置:相对位置;
    字体:16px塔荷马,无衬线;
    }
    #主要的{
    保证金:0自动;
    显示:块;
    }
    a{
    文字装饰:无;
    }
    导航ul{
    显示:无;
    }
    导航ul li:悬停>ul{
    背景:无重复滚动0 0#F37124;显示:块;边距:0;
    }
    导航ul{
    背景:#f37124;
    列表样式:无;
    位置:静态;
    显示:块;
    填充顶部:15px;
    }
    海军ul:之后{
    内容:“;
    明确:两者皆有;
    显示:块;
    }
    李国荣{
    浮动:左;
    位置:相对位置;
    左:50%;
    左边距:10px;
    右边距:10px;
    }
    nav ul li:悬停{
    }
    nav ul li:悬停a{
    }
    海军ulli a{
    显示:块;
    /*填充:25px 40px*/
    颜色:#111111;
    文字装饰:无;
    位置:相对位置;
    }
    导航ul{
    背景:#ffffff;
    边界半径:0px;
    填充:0px;
    位置:绝对位置;
    最高:100%;
    }
    李国宝{
    浮动:左;
    左:0;
    位置:相对位置;
    文本对齐:左;}
    海军ulli a{
    线高:4;
    填充:0;
    }   
    导航ulli a:悬停{
    背景:#4b545f;
    }
    导航ul{
    位置:绝对;左侧:100%;顶部:0;
    }
    
    不清楚您在问什么。
    header
    {
       background: #f37124;
    }
    
    #nav_main{
        background: #f37124;
        height: 51px;
        text-align: center; 
        margin:0 auto ;
        position:relative; 
        font:16px Tahoma, Sans-serif;
    }
    
    
    a{
        text-decoration: none; 
     }
    
    
    nav ul ul {
        display: none;
    }
    
    nav ul li:hover > ul {
       background: #f37124;                
       display: block;
    }
    
    nav ul {
        background: #f37124;
        list-style: none;
        position: relative;
        display: block;
        padding-top: 15px;
    }
    
    nav ul li {
        float: left;
        position: relative;
        width: 20%;
    }
    nav ul li a {
       display: block; 
       color: #111111; 
       text-decoration: none;
       position: relative;
    }
    
    nav ul ul {
        background: #ffffff; 
        border-radius: 0px; 
        padding: 0px;
        position: absolute; 
        top: 100%;
    }
    
    nav ul ul li {
        float: none; 
        position: relative;
        width: auto;
    }
    
    nav ul ul li a {
         padding: 15px 40px;
    }   
    
    nav ul ul li a:hover {
        background: #4b545f;
    }
    
    <style>
        header{
            background: #f37124;
        }
        #logo{
    
            margin:0 auto; display:block; 
        }
        #nav_main{
            background: #f37124;height: 51px;text-align: center;      margin:0 auto ;
            position:relative; 
            font:16px Tahoma, Sans-serif;
        }
    
        #main_img{
            margin:0 auto; 
            display:block;
        }
        a{
            text-decoration: none; 
        }
    
    
    
    
        nav ul ul {
            display: none;
        }
    
            nav ul li:hover > ul {
                background: none repeat scroll 0 0 #F37124;             display: block;             margin: 0;
    
    
            }
    
    
    
    
        nav ul {
            background: #f37124;
            list-style: none;
            position: static;
            display: block;
            padding-top: 15px;
        }
            nav ul:after {
                content: ""; 
                clear: both; 
                display: block;
            }
    
    
        nav ul li {
            float: left;
            position: relative;
            left: 50%;
            margin-left: 10px;
            margin-right: 10px;
        }
            nav ul li:hover {
    
            }
                nav ul li:hover a {
                                    }
    
            nav ul li a {
                display: block; 
                /*padding: 25px 40px;*/
                color: #111111; 
                text-decoration: none;
                position: relative;
    
            }
    
    
    
    
        nav ul ul {
            background: #ffffff; 
            border-radius: 0px; 
            padding: 0px;
            position: absolute; 
            top: 100%;
        }
            nav ul ul li {
        float: left;
        left: 0;
        position: relative;
        text-align: left; }
                nav ul ul li a {
                       line-height: 4;
                    padding: 0;
    
                }   
                    nav ul ul li a:hover {
                        background: #4b545f;
                    }
    
        nav ul ul ul {
            position: absolute; left: 100%; top:0;
        }
    
    </style>