Если вы можете рассмотреть вложенный элемент, который является встроенным элементом, вы можете рассмотреть эту идею hacky , используя фон и тени:
ul {
padding: 0;
word-break: break-all;
list-style: none;
width: 100px;
border: 1px solid blue;
}
li {
padding: 10px 0;
overflow:hidden; /* don't forget this */
}
.line > *{
padding-bottom:3px; /* this will control the distance of the red underline from the text*/
background:
linear-gradient(#fff,#fff) top /100% calc(100% - 5px), /* this will cover the red gradient of the line above*/
linear-gradient(red,red) bottom/100% 2px; /* this is your border that will show for the last line only */
background-repeat:no-repeat;
/* this shadow will cover the extra red on the right
since the last line cannot completely cover the border of the above line
yes I know it's crazy ...
*/
box-shadow:
5px 0px 0 0px #fff,
10px 0px 0 0px #fff,
15px 0px 0 0px #fff,
20px 0px 0 0px #fff,
25px 0px 0 0px #fff,
30px 0px 0 0px #fff,
35px 0px 0 0px #fff,
40px 0px 0 0px #fff,
45px 0px 0 0px #fff,
50px 0px 0 0px #fff,
55px 0px 0 0px #fff;
}
<ul>
<li><span>woord</span></li>
<li class="line"><span>woooooooooooooooord</span></li>
<li class="line"><span>woooooooooooooooodqsdrd</span></li>
<li class="line"><span>wooood qs q dqoooooooooooodqsdrd</span></li>
<li><span>wooord</span></li>
<li class="line"><span>word</span></li>
<li class="line"><span>wo</span></li>
</ul>