PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, November 9, 2022

[FIXED] How to automatically continue numbering of an ordered list?

 November 09, 2022     css, html     No comments   

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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing