bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

Numbered list-groups with `start` attribute do not count correctly.

Open petschki opened this issue 2 years ago • 7 comments

Prerequisites

Describe the issue

Numbered lists with a start attribute as offset do not count correctly. For example

<ol class="list-group list-group-numbered" start=10>
  <li class="list-group-item">ten</li>
  <li class="list-group-item">eleven</li>
</ol>

start counting from 1

Reduced test cases

A second value for counter-reset fixes the offset, but I do not know how to set this dynamically:

ol.list-group-numbered[start] {
  counter-reset:section 9;
}

What operating system(s) are you seeing the problem on?

Windows, macOS, Android, iOS, Linux

What browser(s) are you seeing the problem on?

Chrome, Safari, Firefox, Microsoft Edge, Opera

What version of Bootstrap are you using?

v5.2.2

petschki avatar Oct 20 '22 10:10 petschki

Any One Working On this Issue

456535688765 avatar Oct 22 '22 08:10 456535688765

https://codepen.io/emdeoh/pen/WNyeNeQ works for me

mdo avatar Oct 22 '22 21:10 mdo

Sorry, its not about <ol>s its about the CSS class .list-group-numbered which cannot have a offset right now. As long as its documented I'm ok with it.

petschki avatar Oct 23 '22 13:10 petschki

see https://codepen.io/petschki/pen/MWXgjBx

petschki avatar Oct 23 '22 13:10 petschki

Oh my bad! Reopening.

mdo avatar Oct 23 '22 16:10 mdo

My two cents! We can use CSS variables.

<ol start="10" class="list-group list-group-numbered" style="--list-start: 10;">
  <li class="list-group-item">list item</li>
  <li class="list-group-item">list item</li>
  <li class="list-group-item">list item</li>
  <li class="list-group-item">list item</li>
</ol>
.list-group-numbered {
  counter-reset: section var(--list-start, 0) !important;
}

https://codepen.io/nkdas91/pen/xxzxXjE

nkdas91 avatar Oct 25 '22 14:10 nkdas91

My two cents! We can use CSS variables.

<ol start="10" class="list-group list-group-numbered" style="--list-start: 10;">
  <li class="list-group-item">list item</li>
  <li class="list-group-item">list item</li>
  <li class="list-group-item">list item</li>
  <li class="list-group-item">list item</li>
</ol>
.list-group-numbered {
  counter-reset: section var(--list-start, 0) !important;
}

https://codepen.io/nkdas91/pen/xxzxXjE

Ok. Your solution is a good idea but you need a -1. Here you can see how: https://codepen.io/matedon/pen/LYqjJVm .list-group-numbered { counter-reset: section calc(var(--list-start, 1) - 1) !important; }

matedon avatar Nov 14 '23 05:11 matedon