I have a webpage with a series of spaced text elements.
There is an absolutely positioned line passing through these text elements as seen below.
I need it to cut off whenever inside the text element as in the line being invisible within the grey area.
Now don't immediately answer with background: black; as there is a non-black background behind the line which I need to show.
Is there any way I can mask the line to not be visible at all when an element is in front of it?
My test code:
<div></div>
<p>Example textExample textExample textExample textExample textExample textExample textExample textExample textExample textExample textExample textExample textExample textExample textExample text</p>
p {
text-align: center;
margin: 45vh 0;
z-index: 2;
padding: 20vw;
position: relative;
}
div {
position: absolute;
margin-left: calc(50vw - 1px);
top: 0;
width:2px;
background: #cfc35d;
height: 100vh;
}
NB: I do not want to use raw pixel values as this is all dynamic content.


