0

I want to create a UL LI decimal list style and a number should be inside a circle like image below.

Do you have any idea?

enter image description here

ul {
      border-left: 1px solid $black;
      // background-color: #f1f1f1;
      list-style-type: none;
      list-style: decimal;
      padding-left: 8px;
  }
<ul>
  <li>Sed ut perspiciatis unde omnis iste natus</li>
  <li>error sit voluptatem accusantium doloremque</li>
  <li>Sed ut perspiciatis unde omnis iste natus</li>
  <li>error sit voluptatem accusantium doloremque</li>
</ul>
abcid d
  • 2,821
  • 7
  • 31
  • 46
  • Why would you want a `ul` when your layout clearly shows you need an `ol`? Also not that in CSS you can only use block comments `/* comment */`. Using `//` makes your CSS invalid and the declarations below the comment might be ignored. – connexo Jun 15 '20 at 16:43
  • Hello @abcidd , did my answer work for you? – Mihail Minkov Jun 15 '20 at 22:03

1 Answers1

5

For this you can't use the predefined list styles, but you can play with the before elements. Also, you'll have to switch to a <ol> because of the numbers. Here, check out this example below.

As for the decimal part, you can probably make a mix between what I show you and this question's accepted answer and second best answer.

ol.special {
  counter-reset: li;
  margin-left: 0;
  padding-left: 0;
  position: relative;
  margin-left: 1rem;
}

ol.special::before {
  width: 1px;
  background-color: black;
  content: " ";
  position: absolute;
  top: 0.8rem;
  bottom: 0.8rem;
}

ol.special li {
  position: relative;
  margin: 0 0 0rem 0;
  padding: 0.5rem 0 0.5rem 1rem;
  list-style: none;
}

ol.special li::before {
  content: counter(li);
  counter-increment: li;
  border-radius: 1rem;
  background-color: white;
  color: black;
  width: 1.25rem;
  height: 1.25rem;
  display: inline-block;
  text-align: center;
  margin-right: 0.5rem;
  margin-left: -1.7rem;
  border: solid 1px black;
  font-weight: bold
}
<ol class="special">
  <li>Element number 1</li>
  <li>Element number 2</li>
  <li>Element number 3</li>
  <li>Element number 4</li>
  <li>Element number 5</li>
  <li>Element number 6</li>
</ol>
Mihail Minkov
  • 2,463
  • 2
  • 24
  • 41