I need to present text in groups of a specific length while still being able to search for text that spans multiple groups on the page. Additionally, I want to include a character above each group.
My current approach is as follows:
body {
margin-top: 1rem;
font-family: mono;
}
br {
margin-bottom: 2rem;
}
span {
margin-right: 1rem;
position: relative;
}
.absolute-before::before {
content: "⇣";
position: absolute;
top: -1.2rem;
left: 0;
color: red;
}
.static-before::before {
content: "⇣";
color: green;
}
<span class="absolute-before">This_is_a_sp</span><span class="absolute-before">lit_string</span>
<br />
<span class="static-before">This_is_a_sp</span><span class="static-before">lit_string</span>
Note: the string and split position are hard-coded here, but are dynamically calculated in the real case.
The first method (using red arrows) visually works fine, but there is an issue with searching for text that spans across groups, particularly in Firefox where the search does not yield results but works in Chromium.
On the other hand, the second method (with green arrows) does not provide a strong visual effect but the search functionality works well.
The problem seems to be related to using position: absolute
in the first method's ::before
pseudo-element, causing the search feature to break.
Do you have any suggestions on how to achieve this? I am open to different approaches (especially excluding the ::before
method), so any ideas are appreciated! It is essential to maintain compatibility with the browser's native Search in page... tool.
Edit:
I came across a Bugzilla bug that also addresses this issue, suggesting that resolving it through the ::before
method may be unlikely. Any alternative solutions are still welcomed!