CSS下拉菜单 - 整个栏正在移动

时间:2016-08-31 11:48:09

标签: html css wordpress

我非常绝望。我想这只是一些愚蠢的错误 - 但是,我很新手,我现在看不到它。

我正在使用Underscores框架创建一个wordpress主题,我的下拉菜单的行为不应该如此。当我使用下拉列表时,整个栏都向下移动。

这是演示: LINK

菜单栏当然应固定在页面顶部。这是CSS:

decimal

经典wordpress菜单:

@media screen and (min-width: 50em) {
.main-navigation,
.main-navigation.toggled {
    position:relative;
    top: 0;
    margin: 0 auto;
    position: fixed;
    z-index: 5;
    min-height: 3em;
}

.nav-menu {
    padding: 0.3em 0 0 0;
    background-color: transparent;
}

.main-navigation ul,
.main-navigation.toggled ul{
    max-height: none;
    padding-left: 0;
    text-align: center;
}

.main-navigation.toggled ul{
    overflow-y: visible;
}

.main-navigation li {
    display: inline-block;
}

.main-navigation ul li {
    position: relative;
}

.main-navigation ul ul {
    outline: 1px solid #333;
}

.main-navigation li li {
    display: block;
    text-align: left;
}

.main-navigation a {
    min-width: 14em;
    max-width: 23em;
}

.main-navigation a,
.main-navigation ul ul li:last-child a {
    border-bottom: none;
}

.main-navigation ul ul.toggle-on {
    position: absolute;
    width: 12em;
    display: block;
    z-index: 10;
    margin-left: 0;
}


.main-navigation ul ul ul.toggle-on {
    position: relative;
}

.main-navigation a {
    min-width: 14em;
    max-width: 23em;
}

.main-navigation.toggled:after {
    display: none;
}

}

有什么建议吗?

1 个答案:

答案 0 :(得分:2)

通过添加" vertical-align:top"检查结果属性到列表项

.main-navigation li {
    display: inline-block;
    vertical-align: top;
}