0

目前,即使我在#menu li li a 中将其指定为文本对齐中心,我在子菜单中的添加主题、删除主题、删除主题、手动抓取也没有集中。子菜单的执行摘要也被切断。我可以知道如何扩展子菜单并集中所有文本吗?谢谢!

这是我的代码(我真的很抱歉,因为我没有 jsfiddle 帐户并且在等待名单上):

HTML

<div id="menu">
<ul>
    <li><a href="#" >Home</a></li>
    <li><a href="#" >Executive Summary</a></li>
    <li><a href="#" > Visual Analytics</a></li> 
    <li><a href="#" >Settings</a>
        <ul>                                        
            <li><a href="#">Add Subject</a></li>
            <li><a href="#">Delete Subject</a></li>
            <li><a href="#"> Edit Subject</a></li> 
            <li><a href="#" >Manual Crawl</a></li>
            <li><a href="#" >Executive Summary</a></li>
        </ul>
    </li>
</ul>

CSS

 #menu {
    position: relative;
    float: left;
    width: 1200px;
    height: 35px;
    font-family: Arial, Helvetica, sans-serif; 
    font-size: 13px;
    padding: 0;
    background: #000;
    text-align: center;
}

#menu ul {
    position: relative;
    list-style: none;
    display: inline-block;
    margin: 0;
    padding: 0;
}

#menu li {
    position: relative;
    float: left;
    height: 100%;
    padding: 0;
    line-height: 35px; 
}

#menu a {
    position: relative;
    height: 100%; 
    width: auto;
    float: left;
    text-decoration: none;
    padding: 0 0 0 25px; 
    margin: 0 3px;
    color: #fff;
    text-align: center;
}

#menu ul ul {
   display: none;
   width: 10em; /* Width to help Opera out */
   background-color: rgba(0,0,0,0.5);
}

#menu li:hover ul {
    display:block;
   position: absolute;
   top: 35px;
   left: 0;
   margin: 0;
   padding: 0;
   z-index: 1; 
}

#menu li li a{
    height: 35px; 
    width: 100%;
    float: left;
    text-decoration: none;
    padding: 0 0 0 25px; 
    margin: 0 3px;
    color: #fff;
    text-align: center;
}

#menu li li a:hover{
   background: rgba(255,255,255,0.5);
}
4

2 回答 2

0
    #menu {
    position: relative;
    float: left;
    width: 1200px;
    height: 35px;
    font-family: Arial, Helvetica, sans-serif; 
    font-size: 13px;
    padding: 0;
    background: #000;
    text-align: center;
}

#menu ul {
    position: relative;
    list-style: none;
    display: inline-block;
    margin: 0;
    padding: 0;
}

#menu li {
    position: relative;
    float: left;
    height: 100%;
    padding: 0;
    line-height: 35px; 
}

#menu a {
    position: relative;
    height: 100%; 
    width: auto;
    float: left;
    text-decoration: none;
     padding: 0px 10px 0px 10px;   
    margin: 0 3px;
    color: #fff;
    text-align: center;
}

#menu ul ul {
   display: none;
   width: 11em; /* Width to help Opera out */
   background-color: rgba(0,0,0,0.5);
}

#menu li:hover ul {
    display:block;
   position: absolute;
   top: 35px;
   left: 0;
   margin: 0;
   padding: 0;
   z-index: 1; 
}

#menu li li a{
    height: 35px; 
    width: 100%;
    float: left;
    text-decoration: none;
    padding: 0px 10px 0px 10px;   
    margin: 0 0px;
    color: #fff;
    text-align: center;
}

#menu li li a:hover{
   background: rgba(255,255,255,0.5);
}
于 2012-09-06T05:21:57.587 回答
0

添加样式

#menu li li a{
    height: 35px; 
    width: 100%;
    float: left;
    text-decoration: none;
    padding: 0 13px; 
    margin: 0 3px;
    display: block;
    color: #fff;
    text-align: center;
}

<a>只有左边的填充,但它必须来自左右两边,或者你可以删除填充

于 2012-09-06T05:28:06.193 回答