Ein schmutziger Trick ist CSS-Zähler zu verwenden, und dann positionieren absolut die Zähler (innerhalb eines ::before`` pseudo-element). To force the underline to extend towards the text, you will have to insert an arbitrary amount of whitespace, in this case I use the em space, represented as
platziert \ 2003 in Unicode
Dieser Trick funktioniert in dem Sinne, dass multiline Inhalt unterstützt, siehe das Proof-of-Concept-Beispiel unten. Außerdem habe ich gerade so zeigen die Optik eine andere Farbe für den Zähler Text verwenden gewählt:
ol {
counter-reset: listCounter;
list-style: none;
}
ol li {
padding-left: 2rem; /* Some arbitrary spacing */
position: relative;
}
ol li::before {
color: #ff0000;
counter-increment: listCounter;
content: counter(listCounter, upper-roman) "\2003\2003\2003";
display: inline-block;
text-decoration: underline;
position: absolute;
left: 0;
max-width: 2rem; /* Must match the left padding above */
overflow: hidden; /* Hide overflowing underline */
}
ol li span {
text-decoration: underline;
}
<ol type="I">
<li><span>Non-Canadian Investors</span>
<p>Cce or information to anyone </p>
</li>
<li><span>This is a very long title This is a very long title This is a very long title This is a very long title This is a very long title This is a very long title</span>
<p>Cce or information to anyone </p>
</li>
</ol>