在wordpress中定位最后一个子项下拉菜单?

时间:2016-01-21 10:06:08

标签: css wordpress wordpress-theming

下拉菜单可以正常使用我的主题,但是对于最后一个子菜单没有什么问题,例如修复文本位置无法移动到附近的另一个子菜单以及如何删除最后一个子菜单的透明度背景,如我的概念下面: drop-down menu

css for下拉菜单

.navbar-default {
    box-shadow: 0 2px 10px rgba(0,0,0,0.67);
    background: #fff;
    background: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zd…IxIiBoZWlnaHQ9IjEiIGZpbGw9InVybCgjdG9wVG9Cb3R0b21HcmFkaWVudCkiLz48L3N2Zz4=);
    background: -moz-linear-gradient(top, #fff 0, #e6e6e6 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #fff), color-stop(100%, #e6e6e6));
    background: -webkit-linear-gradient(top, #fff 0, #e6e6e6 100%);
    background: -o-linear-gradient(top, #fff 0, #e6e6e6 100%);
    background: -ms-linear-gradient(top, #fff 0, #e6e6e6 100%);
    background: linear-gradient(to bottom, #fff 0, #e6e6e6 100%);
    width: 100%;
    height: 44px;
    border-width: 0 0 1px;
    border-style: solid;
    border-color: #fff;
    position: relative;
    margin-top: 5px;
}

.navbar-default .navbar-collapse, .navbar-default .navbar-form {
    border-color: #e7e7e7;
    position: relative;
    z-index: 20;
}

.navbar-nav {
    background: url(img/logo.png) no-repeat scroll right/ 91% 100%;
    z-index: 0;
    position: absolute;
    left: 0;
    right: 0;
    height: 0
}

.navbar-nav a {
    display: block;

}

.navbar-nav li {
    display: block;
    /* margin: 0 47%; */
    padding: 0;
    /* width: 180px; */
    /* height: 138px; */
    /* text-indent: -999em; */
    direction: ltr;
    float: none;
}

.navbar-nav li:hover .dropdown-menu {
    opacity: 1;
    top: 105px;
    visibility: visible;
}

.navbar-default .navbar-nav>li>a {
    color: transparent;
    background: url(img/logo.png) no-repeat scroll right/ 91% 100%;
    display: block;
    margin: -33px auto 0 auto;
    width: 180px;
    height: 150px;
    /* text-indent: -999em; */
    direction: ltr;
    float: none;
}

.navbar-default .navbar-nav>.open>a, .navbar-default .navbar-nav>.open>a:hover, .navbar-default .navbar-nav>.open>a:focus {
    background: url(img/logo.png) no-repeat scroll right/ 91% 100%;
    color: transparent;
    display: block;
    margin: -33px auto 0 auto;
     width: 180px;
    height: 150px;
    direction: ltr;
    float: none;
}

.navbar-default .navbar-nav>li>a:hover, .navbar-default .navbar-nav>li>a:focus {
    color: transparent;   
}

.navbar-default .navbar-nav>.open>a, .navbar-default .navbar-nav>.open>a:hover, .navbar-default .navbar-nav>.open>a:focus {
   background: url(img/logo.png) no-repeat scroll right/ 91% 100%;
    color: transparent;
    display: block;
    margin: -33px auto 0 auto;
     width: 180px;
    height: 150px;
    direction: ltr;
    float: none;
    }

.navbar-default .navbar-nav>.active>a, .navbar-default .navbar-nav>.active>a:hover, .navbar-default .navbar-nav>.active>a:focus {
    color: transparent;
    background-color: transparent;
}

.navbar-default .navbar-nav>.open>a, .navbar-default .navbar-nav>.open>a:hover,  .navbar-default .navbar-nav>.open>a:focus {
    background: url(img/logo.png) no-repeat scroll right/ 91% 100%;
    color: transparent;
    display: block;
    margin: -33px auto 0 auto;
     width: 180px;
    height: 150px;
    direction: ltr;
    float: none;

}


.navbar-nav ul {
}

.nav .open>a, .nav .open>a:hover, .nav .open>a:focus {
    /* background-color: #eeeeee; */
    border-color: #337ab7;

}

.navbar-nav>li>.dropdown-menu {
    margin: -1px 0 0 45%;
    border-top-right-radius: 0;
    border-top-left-radius: 0;

}

.dropdown-menu {
    /* background: url(img/submenu.png) no-repeat scroll right/ 91% 100%; */
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    display: none;
    float: left;
    min-width: 153px;
    padding: 1px 0;
    margin: 2px 0 0 0;
    list-style: none;
    font-size: 14px;
    text-align: center;
    background-color: #5c4d4a;
    border: 1px solid #ccc;
    border: 1px solid rgba(0,0,0,0.15);
    border-radius: 4px;
    -webkit-box-shadow: 0 6px 12px rgba(0,0,0,0.175);
    box-shadow: 0 6px 12px rgba(0,0,0,0.175);
    background-clip: padding-box;
    opacity: 0;
    top: 35px;
    visibility: hidden;
    -webkit-transition: all .25s ease;
    -moz-transition: all .25s ease;
    -ms-transition: all .25s ease;
    -o-transition: all .25s ease;
    transition: all .25s ease;
}

.dropdown-menu li a {
    display: block;
    background: url(img/submenu.png) no-repeat scroll right/ 104% 108%;
    padding: 10px 20px;
    clear: both;
    font-weight: normal;
    line-height: 1.428571;
    color: #fff;
    white-space: nowrap;

}
.dropdown-menu li a:hover,
.dropdown-menu li a:focus {
    background: url(img/submenu.png) no-repeat scroll right/ 104% 108%;
    color: #ccc;
    text-decoration: none;
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff357ebd', GradientType=0);
      -webkit-transition: all .25s ease;
       -moz-transition: all .25s ease;
        -ms-transition: all .25s ease;
         -o-transition: all .25s ease;
            transition: all .25s ease;
}

.dropdown-menu li:last-child a {
    display: block;
    background: url(img/submenu.png) no-repeat scroll right/ 104% 108%;
    padding: 10px 20px;
    clear: both;
    font-weight: normal;
    line-height: 1.428571;
    color: #fff;
    white-space: nowrap;

}

.dropdown-menu   li:last-child a:hover,
.dropdown-menu   li:last-child a:focus
 {

    color: #000;
    text-decoration: none;
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff357ebd', GradientType=0);
      -webkit-transition: all .25s ease;
       -moz-transition: all .25s ease;
        -ms-transition: all .25s ease;
         -o-transition: all .25s ease;
            transition: all .25s ease;
}

.dropdown-menu ul { 

list-style: none; 

}

有关详细信息,请查看my theme。谢谢你。

3 个答案:

答案 0 :(得分:1)

如果您想将文字放在最上面,可以将.dropdown-menu li:last-child a更改为:

.dropdown-menu li:last-child a {
    padding-left: 20px;
    padding-right: 20px;
    padding-top: 10px;
    padding-bottom: 52px;
}

如果您要删除透明背景,但.dropdown-menu中有菜单阴影,则必须在底部添加此规则:

.dropdown-menu {
    ...

    border-bottom-right-radius: 77px;
    border-bottom-left-radius: 77px;
}

答案 1 :(得分:0)

更改

.dropdown-menu li:last-child a {
    padding: 31px 20px;
}

.dropdown-menu li:last-child a {
    padding-left: 20px;
    padding-right: 20px;
    padding-top: 10px;
    padding-bottom: 70px;
}

答案 2 :(得分:0)

可以获得所需的效果:

.dropdown-menu li:last-child a {
     padding: 8px 20px 62px 20px
}