Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

HTML list with number/circles, text aligment inside circles

I am trying to create a list with circles at the left side of the list with numbers inside. I got it work and can edit the circle styling, but I don’t get it aligned right with the list items. Heres the HTML:

<ol class="circle"> 
  <li class="li">item</li> 
  <li class="li">item</li> 
  <li class="li">item</li> 
  <li class="li">item</li> 
</ol>

And the CSS:

.circle {
    list-style: none;
    counter-reset: item;
    vertical-align: middle;
  }

.li {
    counter-increment: item;
    margin-left: 0.5em;
    margin-top: 3em;
    margin-bottom: 3em;
    vertical-align: middle;
  }

.circle > li:before {
    background-color: #a879e198;
    color: #a2a2a2 !important;
    content: counter(item);
    border-radius: 100%;
    margin-right: 1em;
    top: 50%;
    height: 3em;
    width: 3em;
    text-align: center;
    display:inline-block;
}

.circle > li:hover::before {
    box-shadow: 0 0 0 3px #a879e14b;
}

Result in the fiddle: https://jsfiddle.net/5owe2371/10/

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How I get the circles align with the text or number inside the circle always in the middle of circle? Latter might be even better to apply same principle later in other ways.

>Solution :

Easy you just need to add 2 lines to this class

.circle > li:before {
    ...
    vertical-align: middle;
    line-height: 3em;
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading