<li>标签在使用mmenu时会堆叠

时间:2016-04-06 13:07:35

标签: javascript jquery html css mmenu

我正在使用mmenu jquery library在我的网站上制作移动菜单。我在我的网站中复制粘贴的确切实现代码并且mmenu正在工作,但菜单内的<li>行相互堆叠。我相信mmenu <nav>的css规则正在从容器div中获取一些css规则。当我尝试使用mmenu网站上提到的基本示例(我的实现方法)时,菜单内部的行堆积甚至发生。

请帮我解决这个问题。

可以找到实际的mmenu示例here

我的实施截图:

enter image description here

<nav id="menu">
    <ul>
        <li>
            <a href="#/">
                <i class="fa fa-home"></i> 
                Home
                </a>
        </li>
        <li>
            <a href="#/about">
                <i class="fa fa-user"></i> 
                About us
            </a>
        </li>
        <li>
            <a href="#/contact">
                <i class="fa fa-envelope"></i> 
                Contact
            </a>
        </li>
    </ul>
</nav>
jQuery(document).ready(function($) {
    $("#menu").mmenu({
        extensions: [ 
            "theme-black", 
            "effect-menu-zoom", 
            "effect-panels-zoom", 
            "pagedim-black" 
        ],
        navbar: false,
        navbars: {
            height: 4,
            content: [ 
                '<a href="#/" class="fa fa-phone"></a>',
                '<img src="http://lorempixel.com/60/60/people/1/" />',
                '<a href="#/" class="fa fa-envelope"></a>'
            ]
        }
    }).on('click', 'a[href^="#/"]', function() {
        alert("Clicked");
        return false;
    });
});
.mm-menu {
    background: #440011 !important;
}
.mm-navbar {
    text-align: center;
    position: relative;
    border-bottom: none;
}
.mm-navbar:before {
    content: "";
    display: inline-block;
    vertical-align: middle;
    height: 100%;
    width: 1px;
}
.mm-navbar > * {
    display: inline-block;
    vertical-align: middle;
}
.mm-navbar img {
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 60px;
    width: 60px;
    height: 60px;
    padding: 10px;
    margin: 0 10px;
}
.mm-navbar a {
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 40px;
    color: rgba(255, 255, 255, 0.6) !important;
    font-size: 16px !important;
    line-height: 40px;
    width: 40px;
    height: 40px;
    padding: 0;
}
.mm-navbar a:hover {
    border-color: #fff;
    color: #fff !important;
}
.mm-listview {
    text-transform: uppercase;
    font-size: 12px;
}
.mm-listview li:last-child:after {
    content: none;
    display: none;
}
.mm-listview li:after {
    left: 20px !important;
    right: 20px !important;
}
.mm-listview a {
    text-align: center;
    padding: 30px 0 !important;
}
.mm-listview a,
.mm-listview .fa {
    color: rgba(255, 255, 255, 0.6);
}
.mm-listview a:hover,
.mm-listview a:hover .fa {
    color: #fff;
}
.mm-listview .fa {
    position: absolute;
    left: 20px;
}

html.mm-opened.mm-effect-zoom-menu body
{
    background: #f3f3f3;
}
html.mm-opened.mm-effect-zoom-menu.mm-theme-dark body
{
     background: #333;
}
html.mm-opened.mm-effect-zoom-menu.mm-theme-black body
{
    background: #000;
}
html.mm-opened.mm-effect-zoom-menu.mm-theme-white body
{
    background: #fff;
}
html.mm-opened.mm-effect-zoom-menu .mm-page
{
    background-color: #fff;
}

.mm-menu li .fa
{
    margin: 0 20px 0 5px;
    font-size: 16px;
    width: 12px;
}
.mm-menu li[class*="mm-tile"] .fa
{
    margin: 0;
    line-height: 0;
}

.mm-menu .buttonbar-item:after
{
    content: none !important;
    display: none !important;
}

编辑 删除position:absolute后,按照答案中的指导,我将获得<li>单行 enter image description here

1 个答案:

答案 0 :(得分:1)

您为fa课程提供了链接,然后绝对定位。容器没有相对定位,所以他们只是从屏幕上读取它。

        .mm-listview .fa {
            position: absolute;
            left: 20px;
        }