html - 显示 :table-cell element has a wrong alignment on Firefox 内的 Bootstrap NAV 元素

标签 html css twitter-bootstrap

考虑这个 HTML 标记(包括 Bootstrap 库):

<div class="container">
  <div class="card">
    <ul class="nav list">
      <li class="element">
        <a href="#">Element</a>
        </li>
      <li class="element">
      <a href="#">Another element</a>
        </li>
    </ul>
    <div class="content">
     <div>
       First content
     </div>
     <div>
       Second content
     </div>
    </div>
  </div>
</div>

和这个 CSS 代码:

.container { 
  display: table;
  layout: table-fixed;
}
.card {
  display: table-row;
  width: 300px;
}

li {
  display: inline-block;
  background-color: red;
  padding: 20px;
}

.list {
  display: table-cell;
  width: 100px;
  white-space: nowrap;
}

.content {
  display: table-cell;
  width: 200px;
  background-color:blue;
  height: 200px;
}

我已经用谷歌搜索了很多,但仍然无法理解为什么 Firefox 显示的代码与 Chrome 不同。它只是为带有导航栏的表格单元格 div 提供某种填充/边距,然后它不与顶部的其他内容表格单元格对齐。看图片:

Firefox

Chrome

有人在使用 Firefox/Bootstrap 时遇到过这种问题吗?我将不胜感激任何帮助,提前致谢!

现场演示:https://jsfiddle.net/9cztjd6o/3/

最佳答案

此间隙是一个空文本行,由默认 Bootstrap “:before”样式引起。你可以用类似的东西隐藏它:

.container:before, .list:before {
  display: none;
}

关于html - 显示 :table-cell element has a wrong alignment on Firefox 内的 Bootstrap NAV 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34563832/

相关文章:

html - 使用 css3 的 SVG 阴影

javascript - JQuery 使用 Bootstrap 4 验证表单输入和突出显示标签

jquery - 导航栏菜单 Bootstrap 上的无关行

html - 如何在 MySQL 中转换 HTML 字符引用?

html - 用于将元素拆分为动态数量的列的纯 CSS 解决方案

javascript - 选择新元素时自动更改输入值

javascript - Bootstrap 导航栏居中对齐

php - 评论系统无法通过 php 运行

css - 请用 IE 7/8 帮助我处理此页面

html - 如何让栏目整页变高?