html - CSS 文本对齐不起作用

标签 html css

我的 CSS 有什么问题:文本没有像我期望的那样居中

参见 https://jsfiddle.net/L5bgrg8d/

  <html>
  <head>
    <title>

    </title>
    <link rel="stylesheet" href="style.css">
  </head>
  <body>
    <div id="container">
      <div id="header">
        My header
      </div>
      <div id="content">
        <div id="nav"></div>
      </div>
      <div id="footer"></div>
    </div>
  </body>
</html>

样式.css

#header {
  background-color: teal;
  color: white
  text-align: center;
}

最佳答案

在 css 中你漏掉了分号。

#header {
  background-color: teal;
  color: white;
  text-align: center;
}

关于html - CSS 文本对齐不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42314140/

相关文章:

javascript - 减慢 Jquery 滚动的速度

javascript - 如何在移动/桌面 View 中对内容进行不同的设置?

html - 样式在 iOS 手机差距应用程序中无法正确显示

css - 调整子级 div 高度,使其与父级/兄弟级相同

javascript - 使用 img.src 将 img.onload 链接到 Image() 对象

html - 当一个表的宽度很大时,Bootstrap 表不在列中

javascript - 嵌套面板元素内联样式问题

html - 图像始终位于 2 个多列 div 中第二列的右上角

html - 将 x2 图像用于 Retina 显示 CSS

html - 填充背景图像而不是在屏幕调整大小时拉伸(stretch)