左对齐醇数字与标题中相同的“栏”标题、数字

由网友(爱情如毒吸了就放不下)分享简介:有关简单起见,我已经把一切都在HTML部分:<节风格=文本对齐:中心;>< H3>水果和LT; / H3>< OL><李>苹果< /李><李>香蕉< /李><李>桔子< /李>< / OL>&...

有关简单起见,我已经把一切都在HTML部分:

<节风格=文本对齐:中心;>   < H3>水果和LT; / H3>   < OL>     <李>苹果< /李>     <李>香蕉< /李>     <李>桔子< /李>   < / OL> < /节>

如何让的每一个号,发往同一个塔?

对齐

我想获得这样的:

水果 1.苹果 2.香蕉 3.橙子 资深编辑讲解图书表格的几点规范

解决方案

有关只剩下标题对齐列表编号。

体{     文本对齐:中心; } 部分 {     显示:inline-block的;     文本对齐:左; } 醇{     列表样式:无;     填充:0; } OL李{     反增量:步非处方; } OL李:之前{     内容:计数器(步计数器);。 }

<节>     < H3>水果和LT; / H3>     < OL>         <李>苹果< /李>         <李>香蕉< /李>         <李>桔子< /李>     < / OL> < /节>

For the sake of simplicity, I've put everything in the HTML part:

<section style="text-align:center;">
  <h3>FRUITS</h3>
  <ol>
    <li>Apples</li>
    <li>Bananas</li>
    <li>Oranges</li>
  </ol>
</section>

How to make every number of ol to be aligned by the same "column"?

I would like to get this:

FRUITS
1. Apples
2. Bananas
3. Oranges

解决方案

For left align the list numbers with the heading.

body {
    text-align: center;
}
section {
    display: inline-block;
    text-align: left;
}
ol {
    list-style: none;
    padding: 0;
}
ol li {
    counter-increment: step-counter;
}
ol li:before {
    content: counter(step-counter)". ";
}

<section>
    <h3>FRUITS</h3>
    <ol>
        <li>Apples</li>
        <li>Bananas</li>
        <li>Oranges</li>
    </ol>
</section>

阅读全文

相关推荐

最新文章