How to align two columns of text in CSS

我怕爱的太早我们不能终老 提交于 2019-12-02 01:07:11
clairesuzy

As per my comment, I think the best element for the job is an ordered list.

ol {
   font-family: georgia, serif;
   font-size: 16px;
   font-weight: bold;
}
ol li span {
   font-family: arial, sans-serif;
   font-weight: normal;
   font-size: 12px;
}
<ol>
  <li><span>Entry one<br>text on another line</span></li>
  <li><span>Entry two</span></li>
  <li><span>Entry three</span></li>
  <li><span>Entry five</span></li>
  <li><span>Entry six</span></li>
</ol>

With the span to allow changing of font-family between the list "bullets" and the content within, these could be divs if you have block content.

You should just use an appropriately styled ol element, something like this:

See: http://jsfiddle.net/tPjQR/

If you want to have different styles on the number versus the list content, you'll need to wrap the content of each li in something like a span. There just isn't a better way.

ol {
    font-family: Georgia, serif;
}
ol span {
    font-family: Arial, sans-serif;
    font-size: 17px
}
<ol>
    <li><span>Entry one</span></li>
    <li><span>Entry two</span></li>
    <li><span>Entry three</span></li>
    <li><span>Entry five</span></li>
    <li><span>Entry six</span></li>
    <li><span>Entry Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long</span></li>
</ol>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!