【问题标题】:flexbox row and column ul li menu for safari用于 Safari 的 flexbox 行和列 ul li 菜单
【发布时间】:2015-03-18 04:38:05
【问题描述】:
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 代码我正在添加动态菜单所以我使用 flex 框来使宽度统一即使我添加了动态菜单子菜单和另一个子菜单问题是当我在 sarafi 上尝试它时它不是做得很好。但是对于 chrome ie 和 mozilla 来说还可以。 safari 似乎有什么不同,它不起作用

【问题讨论】:

    标签: html css safari flexbox


    【解决方案1】:

    我刚刚将我的导航更改为这个并且它起作用了

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

    【讨论】:

    • 我在 safari 中对其进行了测试,当我检查 about safari 时它显示给我 5.1.7(7534.57.2) 请让我知道这是否与您的相同。如果没有,那么让我们找到一种方法让它为你工作。 @duccom
    • 你可以检查这个小提琴 jsfiddle.net/guradio/5t9r69s9 并在 safari 上打开它,它对我有用,如果它对你有用,请告诉我
    • 谢谢,在 iPad 上的 Safari 中为我工作,都在左边
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-11
    • 1970-01-01
    相关资源
    最近更新 更多