2014-05-18 62 views
0

我需要从自定义CSS下面的代码更改li ul li的CSS,我已经为他们写了一个自定义类,并试图通过WP-ADMIN分配它,但它是不合理的。自定义的CSS为特定的WordPress的菜单项目

<li id="menu-item-10088" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children submenu hover"><a href="http://www.example.com/company/">Company</a> 
<ul class="sub-menu " style="display: block; overflow: hidden; height: 31.90023458481924px; padding-top: 0px; margin-top: 0px; padding-bottom: 0px; margin-bottom: 0px;"> 
    <li id="menu-item-10817" class="menu-item menu-item-type-custom menu-item-object-custom"><a href="http://www.example.com/company/">About Us</a></li> 
    <li id="menu-item-10818" class="aboutus menu-item menu-item-type-custom menu-item-object-custom"><a href="http://www.example.com/company/management-team/">Management Team</a></li> 
    <li id="menu-item-11137" class="aboutus menu-item menu-item-type-custom menu-item-object-custom"><a href="http://www.example.com/company/#company-2">Vision</a></li> 
    <li id="menu-item-10820" class="aboutus menu-item menu-item-type-custom menu-item-object-custom last-item"><a href="http://www.example.com/company/#company-3">Careers</a></li> 
</ul> 
<span class="menu-toggle"></span></li> 

我添加了自定义的类如下,并在相应的WP菜单项

#Header .sub-menu .aboutus li ul li { 
    font-weight: normal; 
    padding: 0; 
    position: relative; 
    width: 100%; 
    } 

提到它,但它没有工作,我需要的是让在上面的代码中提到的菜单项的宽度作为100%

回答

1
<ul class="sub-menu " style="display: block; overflow: hidden; height: 31.90023458481924px; padding-top: 0px; margin-top: 0px; padding-bottom: 0px; margin-bottom: 0px;"> 
    <li id="menu-item-10817" class="menu-item menu-item-type-custom menu-item-object-custom"><a href="http://www.example.com/company/">About Us</a></li> 
    <li id="menu-item-10818" class="aboutus menu-item menu-item-type-custom menu-item-object-custom"><a href="http://www.example.com/company/management-team/">Management Team</a></li> 
    <li id="menu-item-11137" class="aboutus menu-item menu-item-type-custom menu-item-object-custom"><a href="http://www.example.com/company/#company-2">Vision</a></li> 
    <li id="menu-item-10820" class="aboutus menu-item menu-item-type-custom menu-item-object-custom last-item"><a href="http://www.example.com/company/#company-3">Careers</a></li> 
</ul> 

根据你的HTML,li是你的父母li.sub-menu是你的ul和儿童li.aboutus类,所以它应该有如下

#Header li .sub-menu li.aboutus { 
    font-weight: normal; 
    padding: 0; 
    position: relative; 
    width: 100%; 
    } 

即使下面的工作很好,因为你需要不是指li如果sub-menu只会在嵌套li

#Header .sub-menu li.aboutus { 
     font-weight: normal; 
     padding: 0; 
     position: relative; 
     width: 100%; 
     } 
+0

作品般的魅力 –

+0

存在不用谢 :) – mohamedrias