HTML+CSS : Equal distance between footer nav elements without using table

标签 html css

<分区>

Possible Duplicate:
Fluid width with equally spaced DIVs

我正在尝试放置作为文本的页脚元素。我试图让文本元素之间的距离相等。

<nav>
  <ul>
    <li><a>Item Reg</a></li>
    <li><a>Item Sm</a></li>
    <li><a>Item Very Long</a></li>
    <li><a>Item Reg</a></li>
  </ul>
</nav>

这是一张图片,解释了我想要实现的场景。左右元素始终分别向左和向右对齐。 Expected Footer Element Behaviour

如何使用 css 和 html 来实现。注意:允许使用 CSS3。

最佳答案

一种方法是使用百分比表示宽度。

ul {
  width: 100%;
}
ul li {
  display: table-cell;
  width: 25%;
  text-align: center;
}

关于HTML+CSS : Equal distance between footer nav elements without using table,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8804295/

相关文章:

HTML:如何使用 CSS 作为链接样式表添加图像

javascript - 单击 div 时在弹出窗口中打开 YouTube 链接

html - css 中的比例重叠

html - 如何在 html 的导航菜单中间居中标题文本

html - 将行从特定的 td 换行到下一行

html - CSS - 3 个链接 - 左对齐 1,右对齐 2

html - CSS3 slider ,最后一张图片未显示

javascript - Jquery Draggable 占位符拖放

html - 定位 div 以占据宽度的 50%

html - Firefox 显示列表错误