代码作为打击显示一些内,我想选择正确的文本.但现在当鼠标按下SPAN并开始选择文本和鼠标移动到div,一个大的文本被选为图像作为打击.我可以选择正确的文本吗?
enter image description here
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Conditional Text Selection</title>
<style>
.textLayer{
position:absolute;
inset:0;
overflow:hidden;
font-family:monospace !important;
line-height:1;
-webkit-text-size-adjust:none;
-moz-text-size-adjust:none;
text-size-adjust:none;
forced-color-adjust:none;
transform-origin:0 0;
z-index:2;
}
/* .textLayer :is(br) {
user-select: none;
}*/
.textLayer :is(span, br){
position:absolute;
white-space:pre;
cursor:text;
transform-origin:center left;
display: inline;
}
/* 标记选中的文本 */
::selection {
background: yellow;
}
</style>
</head>
<body>
<div class="textLayer" data-main-rotation="0" style="width: 1200px;height: 1300px;--scale-factor: 1.96078431372549;"><span style="left: 10.59%; top: 10.03%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif; transform: scale(0.953561, 0.75);">(or, more broadly, on</span>
<span style="left: 27.13%; top: 10.03%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif;"> </span>
<span style="left: 27.73%; top: 10.03%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif; transform: scale(0.914235, 0.75);">mathematics</span>
<span style="left: 37.43%; top: 10.03%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif;"> </span>
<span dir="ltr" style="left: 38.22%; top: 10.03%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif; transform: scale(0.962099, 0.75);" aria-owns="pdfjs_internal_id_321R">generally).</span>
<span style="left: 46.35%; top: 9.81%; font-size: calc(var(--scale-factor)*7.97px); font-family: sans-serif; transform: scale(0.881791, 0.75);">42</span>
<span style="left: 47.73%; top: 9.81%; font-size: calc(var(--scale-factor)*7.97px); font-family: sans-serif;"> </span>
<span dir="ltr" style="left: 48.65%; top: 10.03%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif; transform: scale(0.945475, 0.75);" aria-owns="pdfjs_internal_id_322R">To illustrate this converse, I single out five events in</span>
<br role="presentation"><span style="left: 10.59%; top: 11.74%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif; transform: scale(0.912819, 0.75);">five different areas of mathematics (Figure 3), triggered or made possible by logic-based developments</span>
<br role="presentation"><span style="left: 10.59%; top: 13.45%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif; transform: scale(0.932114, 0.75);">in computer science, with each event deserving the distinction of being ‘first’ in its respective area:</span>
<br role="presentation"><span style="left: 13.25%; top: 16.28%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif;">•</span>
<span style="left: 14.15%; top: 16.28%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif;"> </span>
<span style="left: 15.04%; top: 16.28%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif; transform: scale(0.912485, 0.75);">Boolean algebra</span>
<span style="left: 27.3%; top: 16.28%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif;"> </span>
<span style="left: 28.22%; top: 16.28%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif; transform: scale(0.970179, 0.75);">– a formal proof that every Robbins algebra is a Boolean algebra, using the</span>
<br role="presentation"><span dir="ltr" style="left: 15.04%; top: 18%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif; transform: scale(0.946777, 0.75);" aria-owns="pdfjs_internal_id_323R">automated theorem-prover EQP (1997).</span>
<span style="left: 46.2%; top: 17.78%; font-size: calc(var(--scale-factor)*7.97px); font-family: sans-serif; transform: scale(0.881791, 0.75);">43</span>
<br role="presentation"><span style="left: 13.25%; top: 20.21%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif;">•</span>
<span style="left: 14.15%; top: 20.21%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif;"> </span>
<span style="left: 15.04%; top: 20.21%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif; transform: scale(0.929563, 0.75);">Graph theory</span>
<span style="left: 25.08%; top: 20.21%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif;"> </span>
<span style="left: 25.75%; top: 20.21%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif; transform: scale(0.906408, 0.75);">– a formal proof of the Four-Color Theorem using the automated interactive proof-</span>
<br role="presentation"><span dir="ltr" style="left: 15.04%; top: 21.92%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif; transform: scale(0.919253, 0.75);" aria-owns="pdfjs_internal_id_324R">assistant Coq (2008).</span>
<span style="left: 31.51%; top: 21.7%; font-size: calc(var(--scale-factor)*7.97px); font-family: sans-serif; transform: scale(0.881791, 0.75);">44</span>
<br role="presentation"><span style="left: 13.25%; top: 24.15%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif;">•</span>
<span style="left: 14.15%; top: 24.15%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif;"> </span>
<span style="left: 15.04%; top: 24.15%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif; transform: scale(0.948306, 0.75);">Group theory</span>
<span style="left: 25.34%; top: 24.15%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif;"> </span>
<span style="left: 26.24%; top: 24.15%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif; transform: scale(0.94688, 0.75);">– a formal proof of the Odd-Order Theorem, also known as the Feit-Thompson</span>
<br role="presentation"><span dir="ltr" style="left: 15.04%; top: 25.84%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif; transform: scale(0.935484, 0.75);" aria-owns="pdfjs_internal_id_325R">Theorem, using the automated interactive proof-assistant Coq (2012).</span>
<span style="left: 69.61%; top: 25.63%; font-size: calc(var(--scale-factor)*7.97px); font-family: sans-serif; transform: scale(0.881791, 0.75);">45</span>
<br role="presentation"><span style="left: 13.26%; top: 28.07%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif;">•</span>
<span style="left: 14.15%; top: 28.07%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif;"> </span>
<span style="left: 15.04%; top: 28.07%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif; transform: scale(0.909879, 0.75);">Three-dimensional geometry</span>
<span style="left: 36.86%; top: 28.07%; font-size: calc(var(--scale-factor)*10.91px); font-family: sans-serif;"> </span>
</div>
</body>
</html>
字符串
我期望:enter image description here实际结果:enter image description here
1条答案
按热度按时间4urapxun1#
会告诉问题是PDF源/转换,你可以合并它有点像这里讨论的Reorganize PDF or HTML content for a blind user?或使用更好的转换器。
如果我只是从pdf.js复制HTML(比如在Firefox中),我可能会得到更好的输出,比如:
字符串
选择可能正常工作。
如果我再次尝试您的代码并更改此处提到的指针事件,
position: absolute
似乎会更好地工作。边界添加了更好的元素方向。