Line Number Alignment in Text Wrapping
As you can see in the video, when line wrapping is enabled, line numbers do not represent the corresponding lines. On the other hand, in the screenshot, the way lines wrap around and create space between the line numbers positions the line numbers with the corresponding lines.
I asked ChatGPT for help but he wasn't that helpful :(
4 Replies
Here are the codes:
html
css
javascript
Anyone?
Can be done way easier, don't even need js
you can style li::marker for the numbering, or create it from scratch with a pseudo element and the counter() property
https://codepen.io/MarkBoots/pen/BaeKBzZ
--edit. hmm, i just noticed preventing the first li to be deleted does not work. I'll try to figure that out. (maybe we do need a bit of js for that)
wondering if maybe something like
ol:has(li:first-child:empty) li:first-child::before {content: '1.'; }
mostly relying on the :empty
pseudo-class or maybe :only-child
. this approach though is genius just having the content-editable on the ol allows you to create lists like that! or perhaps
Thank you both. I'll try this