【问题标题】:Flexbox not working in buttons in FirefoxFlexbox 在 Firefox 的按钮中不起作用
【发布时间】:2014-08-08 23:13:08
【问题描述】:

显然 Firefox 不喜欢按钮上的display: flex。有没有办法解决这个问题?

CSS:

button {
    width: 100%;
    display: -webkit-box;
    display: -webkit-flex;
    display: -moz-box;
    display: -ms-flexbox;
    display: flex;
}

    button div:first-child {
        -webkit-box-ordinal-group: 2;
        -webkit-order: 2;
        -moz-box-ordinal-group: 2;
        -ms-flex-order: 2;
        order: 2;
    }

    button div:last-child {
        -webkit-box-ordinal-group: 1;
        -webkit-order: 1;
        -moz-box-ordinal-group: 1;
        -ms-flex-order: 1;
        order: 1;
    }

HTML:

<button>
    <div>
        <p>First</p>
    </div>
    <div>
        <p>Second</p>
    </div>
</button>

现场演示:http://jsbin.com/ziwadabo/2

【问题讨论】:

    标签: css firefox flexbox


    【解决方案1】:

    tl;dr:只需在您的 &lt;button&gt; 中添加一个 div,然后将 that 设为 div display:flex

    请参阅https://bugzilla.mozilla.org/show_bug.cgi?id=984869#c2,了解为什么 display 在 Firefox 中的 &lt;button&gt; 无法达到您的预期效果(以及出于类似原因在 Firefox 或 Webkit/Blink 中不起作用的类似事情)。

    这是您修改后的 jsbin:http://jsbin.com/ziwadabo/4/

    【讨论】:

    • 有趣,我想这是有道理的。愚蠢的系统级元素,总是把事情搞砸。谢谢!
    • @jbergloff,这与这个线程有什么关系?有人建议将哪一段短语内容放在此处的按钮中?
    • &lt;div&gt; 内的 &lt;button&gt; 不会通过 W3C 验证(您将收到 Element div not allowed as child of element button in this context 错误)。但你可以改用&lt;span&gt;
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-23
    • 2019-02-19
    • 1970-01-01
    • 2015-06-28
    • 2013-09-07
    • 1970-01-01
    相关资源
    最近更新 更多