I have the following code that creates automatic line numbers for each div with the class "lineNum". I want to create line numbers also for line breaks (in a code snippet, the line between lines 1 and 2). Thank!
.container {direction:rtl; counter-reset: line;}
.container .lineNum {display: flex;line-height: 1.5rem;}
.lineNum>center, .lineNum>right, .lineNum>left, .lineNum>span
{width: 100%;}
.container .lineNum:before
{
width: 2%;font-weight: bold;
counter-increment: line;content:counter(line);
display: inline-block;
background-color: lightgray;
margin-left: 10px;
padding-right: .5em;
}
<div class="container">
<div class="lineNum"><span>ืืืืื ืชืงืืคื ืื, ืืืื ื ืืงืืืฆื ืงืื ื ืฉื ืขืืจืืื ืืงืืืื ืืืืื ืช ืฉื ืขืืจืืื, ืืคืชืืื, ืงืืจืืื, ืชืืจืืื ืืฉืืชืคืื. ืืืคื ื ืืื ืืขืื 15 ืฉื ื? ืืืื ืชืคืงืื ื ืืื ืืขืืื? ืื ืขืื ืืฆืืจืฃ ืืชื ืืขื? ืื ืืืคื ืืขืืืื ืื ืืฆืืช ืืคื ืื ื? ืฉืืืืช ืืื ืืืขื ื ืขื ืืื ืชื ืืขืช ืืืงืืืืื ืืืื ืืืืื ืืฉืืืขืืช ืืงืจืืืื, ืืืกืืจืช ืืชืืืื ืืืกืืจืืื ืืฉื ืช 2017, ืืืชื ืื ืืืืื ืืื.</span></div>
<div class="lineNum"><span>ืชืฆืืื ืืืืืื ืฉื ืืจืฅ ืืฉืจืื, ืืฉื ืช 2003, ืืืืื ืืช ืืืื ืช ืืฉืจืื, ืฉืืื ืืจืฉืืช ืืคืืกืืื ืืช, ืืืืงืื ืืืจืื, ืืื ืื, ืกืืจืื ืืืฆืจืื</span></div></div>
Run codeedit: next result expected

source
share