【问题标题】:Positioning last child drop-down menu in wordpress?在wordpress中定位最后一个子下拉菜单?
【发布时间】:2016-01-21 18:30:32
【问题描述】:

下拉菜单在我的主题上运行良好,但对于最后一个子菜单来说几乎没有问题,比如修复文本位置不能移动到另一个子菜单附近的顶部,以及如何像我的概念一样删除最后一个子子菜单的透明背景以下:

下拉菜单的 CSS

.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。之前谢谢。

【问题讨论】:

    标签: css wordpress wordpress-theming


    【解决方案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;
    }
    

    【讨论】:

      【解决方案2】:

      改变

      .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;
      }
      

      【讨论】:

        【解决方案3】:

        要获得所需的效果,您可以:

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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2017-06-09
          • 1970-01-01
          • 2017-02-17
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多