【问题标题】:left align text in the middle of the page在页面中间左对齐文本
【发布时间】:2018-03-17 16:58:40
【问题描述】:
.equiv {
  margin: auto;
  display: table;
}
.equiv .eso {
  display: table-cell;
}

我使用这些样式来使容器 .equiv 居中对齐,并保持其内容(在 .eso 中)左对齐:

<div class="equiv">
  <div class="eso">
    <p>Consider this text<br>
      as a verse of a poem<br>
      that is left aligned<br>
      but in the middle of the page.</p>
    <p>(The middle of the page<br>
      corresponds to the middle<br>
      of the largest line of course).</p>
  </div>
</div>

嗯,它适用于 Firefox 和 Chrome,但不适用于 Explorer,其中文本只是左对齐(但不在中间)。
有解决办法吗?

【问题讨论】:

  • 它似乎在所有三种浏览器中都适用于我 (jsfiddle.net/swm53ran/434)。你用的是什么版本的ie?
  • @indubitablee 嗯。看来你是对的。当我只测试代码时就可以了。当我将它与页面中的其他元素一起测试时,它不起作用。我必须看得更深...谢谢
  • 您能告诉我答案中缺少什么吗?以便我调整并接受。

标签: html css text-align


【解决方案1】:

实际上这很简单,您拥有所需的所有包装器。

.equiv {
  text-align: center;
}
.eso {
  display: inline-block;
  text-align: left;
}

【讨论】:

    猜你喜欢
    • 2015-06-08
    • 2015-02-12
    • 2017-04-07
    • 1970-01-01
    • 2010-11-28
    • 2014-07-27
    • 2014-12-12
    • 1970-01-01
    • 2018-01-05
    相关资源
    最近更新 更多