如何在“之前”应用伪元素。在多行程中
在下面的图像上,我有两个跨度:一个带有红色边框的跨度(在第一行的一部分附近),另一个带有绿色边界(第二行和第三行的一部分)。如您所见,第二个跨度正确地包裹了两行。
然后,我将这两个跨度(当然是“显示:相对”跨度)与“伪元素”之前的红色和绿色alpha背景(出于与重叠注释规格链接的特定原因(出于特定原因) ,与此主题无关,是这样构建的伪元素:
@mixin annotColors($color, $alpha) {
border-color: $color!important;
&:before {
content: '';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: rgba($color, $alpha);
pointer-events: none;
}
}
$annot-base-alpha: .25;
&[data-annottype="dft"] { @include annotColors($color-annot-default, $annot-base-alpha); }
&[data-annottype="sugg"] { @include annotColors($color-annot-suggestion, $annot-base-alpha); }
&[data-annottype="good"] { @include annotColors($color-annot-good, $annot-base-alpha); }
&[data-annottype="err"] { @include annotColors($color-annot-error, $annot-base-alpha); }
&[data-annottype="hvy"] { @include annotColors($color-annot-heavy, $annot-base-alpha); }
&[data-annottype="xhw"] { @include annotColors($color-annot-comprehension, $annot-base-alpha);
正如您所看到的,第二个(绿色)背景不符合其多层次的跨度,而是[左至左下行,右半线]区域。您是否知道我该如何强制:在“同伴”的“多利父母”之前?
On the following image, I have two spans: one with red border (around a part of the first line) and one with green borders (around a part of second and third line). The second span, as you see, correctly wrap in two line.
Then, I link those two spans ("display: relative" spans, of course) with corresponding red and green alpha backgrounds in ":before" pseudo-elements (for specific reasons linked to overlapping annotations specifications, not related to this topic), pseudo-elements constructed like this:
@mixin annotColors($color, $alpha) {
border-color: $color!important;
&:before {
content: '';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: rgba($color, $alpha);
pointer-events: none;
}
}
$annot-base-alpha: .25;
&[data-annottype="dft"] { @include annotColors($color-annot-default, $annot-base-alpha); }
&[data-annottype="sugg"] { @include annotColors($color-annot-suggestion, $annot-base-alpha); }
&[data-annottype="good"] { @include annotColors($color-annot-good, $annot-base-alpha); }
&[data-annottype="err"] { @include annotColors($color-annot-error, $annot-base-alpha); }
&[data-annottype="hvy"] { @include annotColors($color-annot-heavy, $annot-base-alpha); }
&[data-annottype="xhw"] { @include annotColors($color-annot-comprehension, $annot-base-alpha);
And as you can see, the second (green) background does not fit its multilined span, but rather it's [left-first line, right-last line] zone. Would you have any idea how I could force that :before to "fellow" it multilined parents?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,我找到了一个非常可怕的解决方案,但至少它有效。代替:
用:
的每个字母包裹在xml标签中(selection = selection.replaceall(/
(
我将文本 (尤其是对于大型选择),但就我而言,它没有导致任何渲染问题。
OK, I found a quite horrible solution, but at least it works. In place of having:
with:
I wrap each letters of the text in an xml tag (selection = selection.replaceAll(/(.)/g, '$1')):
which hold the :before translucid color:
That overloads the innerHTML (especially for big selections), but as far as I tried it results in no rendering problem.