我想要显示一些文本,分成给定长度的组,但不是retain the ability to search the page for text that spans multiple groups.有了这个,我想在每个组上面显示一些字符.
我最终得到的解决方案是以下一个:
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 one (red arrows) makes the visual part of the job is perfectly fine, but the problem is that, in Firefox (tested in Chromium, where it works), searching the page for the text split
, which is split between the two groups, gives no results.
The second one (green arrows), conversely, does not give a good visual but the search feature works well.
The difference is in the position: absolute
on the ::before
in the first one, which seems to break the search feature.
你对如何做到这一点有什么线索吗?我不确定实现这一点的方式(特别是::before
方式),所以欢迎任何 idea !唯一的要求是使用浏览器的原生Search in page...工具.
Edit:个
我发现Bugzilla bug也报告了这个问题.因此,使用::before
方法😪似乎不太可能解决这个问题.仍然欢迎任何其他解决方案!