I would like to get a visual plotline layout using li elements inside ul , which would look like this:
li-element1 . . li-element2 . . li-element3
I use the ::before pseudo-element to add a line through the entire ul element, but it is visible on top of the li elements that I don't want to do. How can I bind a string to li and are visible only between field breaks? I have already unsuccessfully tried the Z-index property. here is a link to a pen with my current code.
.container ul{ position: relative; } .container ul::before{ content: ""; position: absolute; top: 0px; bottom: 0px; border: 1px dashed blue; } .container ul li{ margin: 15px; }
<div class="container"> <ul> <li>First</li> <li>Second</li> <li>Third</li> <li>Fourth</li> </ul> </div>
Update
In the original question, I did not pay attention to the fact that the bullets in the li elements are not actually part of the li element itself and, therefore, are not actually affected by any set of background colors set for them. Now, keeping in mind and offering answers, combining the use of z-index, background-color, margin and paddings and additionally setting ul list-style-type: none , I updated the code to:
.container ul{ padding: 0px; margin: 0px; position: relative; list-style-type: none; } .container ul::before{ content: ""; position: absolute; top: 0px; bottom: 0px; left: 16px; border: 1px dotted red; } .container ul li{ margin: 15px; padding: 0px 0px; position: relative; z-index: 1; background-color: white; }
<div class="container"> <ul> <li>• First</li> <li>• Second</li> <li>• Third</li> <li>• Fourth</li> </ul> </div>
source share