Issue
I. Introduction
1. Introduction 1
2. Introduction 2
II. Services
3. Services 1
4. Services 2
As you can see in the above example, the number of the second ol
is started after the last number of the first ol
.
Of course, I found the attribute start
but I want to implement it without using that attribute.
Because using the start
attribute is not dynamic.
If I add one element to the ol
, I should modify all start
attributes after that.
How can I do this?
Solution
We can use a CSS counter to accomplish this, along with some positioning.
.parent-list {
counter-reset: child-count;
}
.parent-list ol li {
list-style-type: none;
position: relative;
counter-increment: child-count;
}
.parent-list ol li::before {
content: counter(child-count)'.';
position: absolute;
left: -1rem;
}
<ol class="parent-list">
<li>Parent One
<ol>
<li>Child One</li>
<li>Child Two</li>
</ol>
</li>
<li>Parent Two
<ol>
<li>Child One</li>
<li>Child Two</li>
</ol>
</li>
</ol>
Answered By - isherwood Answer Checked By - Mary Flores (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.