【问题标题】:Why is position of html button in tablecell different in Firefox为什么 Firefox 中表格单元格中 html 按钮的位置不同
【发布时间】:2015-06-17 19:12:25
【问题描述】:

当嵌套在带有 display: table-cell 的 li 中时,为什么在 Firefox 和 Chrome/IE 中按钮元素的位置不同?

在 Chrome 和 IE 中,按钮与单元格顶部对齐,而在 Firefox 中,按钮与底部对齐。这可以在 Firefox 中影响,使其表现得像在 Chrome 中一样吗?

我在 http://jsfiddle.net/1kg8a6rb/ 上创建了一个小提琴

HTML:

<ul>    
    <li><button><span>Some longer text</span></button></li>
    <li><button><span>Some much longer text</span></button></li>
    <li><button><span>Some text much much more longer text</span></button></li>
    <li><button><span>Some text</span></button></li>
    <li><button><span>Some text</span></button></li>
</ul>

CSS:

ul{
    list-style: none;
    padding: 0;
    margin: 0;
    display: table;
    table-layout: fixed;
    width: 100%;
}
li {
    display: table-cell;
    text-align: center;
}

【问题讨论】:

    标签: html css firefox cross-browser


    【解决方案1】:

    只需将vertical-align:top 添加到table-cellhttp://jsfiddle.net/1kg8a6rb/1/

    【讨论】:

    • 尴尬...我确信我已经尝试过这个:)。谢谢!会接受这个作为答案
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-05-09
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    • 2015-04-11
    • 1970-01-01
    相关资源
    最近更新 更多