简体   繁体   中英

left align text in the middle of the page

.equiv {
  margin: auto;
  display: table;
}
.equiv .eso {
  display: table-cell;
}

I use those styles in order to align center the container .equiv, and keep its contents (in .eso) left aligned:

<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>

well, it works in Firefox and Chrome, but not in Explorer, where the text is simply left aligned (but not in the middle).
Is there a workaround?

That's quite simple actually and you have all the wrappers you need.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM