css - 为什么我的 div 元素没有居中?

标签 css xhtml html

我觉得我缺少一些简单或愚蠢的东西。这是我页面上唯一无法居中的元素。我似乎无法居中ul#footer

http://jsfiddle.net/w67rt/

最佳答案

要水平居中页脚内容,只需添加以下 CSS:

#footer {
  text-align: center;
}

演示:http://jsfiddle.net/mathias/GZ6xh/

如果您希望将整个元素居中,只需给它一个宽度,然后使用 margin: 0 auto:

#footer {
  width: 400px;
  margin: 0 auto;
}

关于css - 为什么我的 div 元素没有居中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5416998/

相关文章:

sql-server - 使用 "FOR XML PATH"时如何避免编码?

asp.net - 如何自动化 HTML 可搜索查询数据并将其导出到 Excel

html - css 相对定位在 chrome 中不起作用

html - 如何在 freemarker 中包含 CSS 文件

css - 垂直导航栏和段落之间的空白

javascript - Angular 2 中的表格

CSS Masking (Webkit) - 一个人如何编码这个圈子?

css - 绝对定位不适用于 XHTML?

html - CSS 无法正常工作

jquery - iOS7 - jquery.touchSwipe 干扰点击和 webkit-touch-callout