Span转换其以下内容CSS

时间:2018-08-24 09:26:13

标签: html css

我正在尝试查找和替换。由于技术限制,我无法直接将查找结果包装在“ span”中以突出显示它们。因此,我必须在背景中复制“ div”,使其内容不可见,然后突出显示结果。问题是,当将结果包装为“ span”时,某些字母的位置如“ T”或“ P”会导致下一个“ span”从1px偏移,从而使整个内容偏移

<div class="highlight" style="position: absolute;color: transparent;line-height: inherit;">
    <span class="findReplace_marker">Toto</span>
    o SOLD OUT
    <span class="findReplace_marker">Toto</span>
    <span class="findReplace_marker">Toto</span>
    <span class="findReplace_marker">Toto</span>
    <span class="findReplace_marker">Toto</span>
    <span class="findReplace_marker">Toto</span>
    <span class="findReplace_marker focused">Toto</span>
</div>


.findReplace_marker {
        background-color: #fdf0c3;
}

示例:

Example

Example

Example

Working Example

0 个答案:

没有答案