如何使用HTML / CSS创建居中的有序列表?

时间:2011-09-21 02:45:30

标签: html css

我想创建一个简单的居中有序列表,如下所示:

    1. one
   2. three
  3. fifteen
    4. two

我正在尝试的所有内容都会使数字与左侧齐平,而不是停留在项目旁边的右侧。我如何得到上面的结果?

1 个答案:

答案 0 :(得分:13)

使用

<style type="text/css">
 .centered { text-align: center; list-style-position:inside;}
</style>    

<ol class="centered">
  <li>one</li>
  <li>three</li>
  <li>fifteen</li>
  <li>two</li>
</ol>