用于safari的flexbox行和列ul li菜单

时间:2015-01-20 03:01:08

标签: html css safari flexbox

nav {
    font-family: Arial, sans-serif;
    border: 1px solid #ccc;
    border-right: none;
    width: 100%;
}
nav ul {
    display: flex;
    flex-pack: center
}
nav ul {
    margin: 0;
    padding: 0;
    display: -ms-flexbox;
    display: -webkit-flex;
    -webkit-flex-flow: row wrap;
    -moz-flex-flow: row wrap;
    -ms-flex-flow: row wrap;
    flex-flow: row wrap;
}

nav ul li {
    list-style: none;
    text-align: center;
    //border-left: 1px solid #fff;
    //border-right: 1px solid #ccc;
    background-color: #feaa38;
    background-image: -webkit-gradient(linear, left top, left bottom, from(#F5F5F5), to(#feaa38));
    background-image: -webkit-linear-gradient(top, #F5F5F5, #feaa38);
    background-image: -moz-linear-gradient(top, #F5F5F5, #feaa38);
    background-image: -o-linear-gradient(top, #F5F5F5, #feaa38);
    background-image: linear-gradient(to bottom, #F5F5F5, #feaa38);
    position: relative;
    -webkit-flex: 1 0 auto;
    -moz-flex: 1 0 auto;
    -ms-flex: 1 0 auto;
    flex: 1 0 auto;
}
nav ul li:hover {
    background-color: #feaa38;
} 
nav ul li a {
    text-decoration: none;
    color: #000;
    display: block;
    padding: 10px 0;
}
nav ul li:hover a {
    color: #FFF;
}
nav ul li ul {
    display: flex;
}
nav ul li ul {
    position:absolute;
    top:-999em;
    display: -ms-flexbox;
    display: -webkit-flex;
    -webkit-flex-flow: column wrap;
    -moz-flex-flow: column wrap;
    -ms-flex-flow: column wrap;
    flex-flow: column wrap;
    justify-content: space-around;
    width:100%;
}








nav ul li:hover > ul{
    top: auto;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    z-index: 9998;
}
nav ul li ul li {
    background: #b56906;
}
nav ul li ul li a {
    text-decoration: none;
    color:#000000 !important;
    display: block;
    padding: 10px 0;
}
nav ul li ul li ul{
    position: absolute; 
    left: 100%;
    display: -webkit-flex;
    display: -moz-flex;
    display: -ms-flex;
    display: -o-flex;
    display: flex;
    -webkit-flex-flow: column wrap;
    -moz-flex-flow: column wrap;
    -ms-flex-flow: column wrap;
    flex-flow: column wrap;
    justify-content: space-around;
    width:100%;
}
nav ul li ul li:hover > ul{
    top: 0;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    z-index: 9999;
}


nav ul li:Last-child {
    border-right: none;
}


<nav>
    <ul>
        <li>
            adasdasdasda
            <ul>
                <li>
                    12321321321
                 <ul>
                <li>
               12adas4asfsafds321321321
                </li>
                <li>
                    56345sdfdsfdsfdssd453543
                </li>
            </ul>
                </li>
                <li>
                    56345453543
                </li>
            </ul>
        </li>
        <li>
            fasffasf
        </li>
        <li>
            asdasdas
            <ul>
                <li>
                    12321321321
                </li>
                <li>
                    56345453543
                </li>
            </ul>
        </li>
    </ul>
</nav>

这是我在css菜单上的代码我正在添加动态菜单所以我使用弹性框使宽度均匀,即使我添加动态菜单子菜单和另一个子菜单问题是当我在sarafi上尝试它不是做得好。但是对于Chrome和mozilla来说还可以。野生动物园似乎有什么不同之处

1 个答案:

答案 0 :(得分:1)

我刚刚将我的nav ul更改为此并且有效

nav ul {
    margin: 0;
    padding: 0;
    display: -webkit-box;
    display: -moz-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: box;
    display: flex;
    -webkit-box-lines: multiple;
    -moz-box-lines: multiple;
    -o-box-lines: multiple;
    -webkit-flex-wrap: wrap;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    -webkit-box-orient: horizontal;
    -moz-box-orient: horizontal;
    -o-box-orient: horizontal;
    -webkit-flex-direction: row;
    -ms-flex-direction: row;
    flex-direction: row;
}