为什么Chrome检查器为SVG中的相同尺寸的元素显示不同的尺寸?

在以下代码段中,Chrome浏览器检查器报告divforeignObjectrect和text节点大50%,即使它们都占用相同的空间屏幕。 Firefox报告这四个大小都相同。是什么导致Chrome报告差异?

<svg viewBox="0 0 300 100" style="width: 300px; height: 100px;">
 <rect fill="#f5f5a0" width="244" height="73"></rect>
 <foreignObject width="244" height="73">
  <div>
   Lorem ipsum dolor sit amet,consectetur adipiscing elit. Vivamus efficitur quam sapien,in varius ipsum mollis quis.
  </div>
 </foreignObject>
</svg>

Chrome检查器结果:

为什么Chrome检查器为SVG中的相同尺寸的元素显示不同的尺寸?

Firefox检查器结果:

为什么Chrome检查器为SVG中的相同尺寸的元素显示不同的尺寸?

lch90120201 回答:为什么Chrome检查器为SVG中的相同尺寸的元素显示不同的尺寸?

这似乎是由Chrome中的一个已知错误引起的:Issue 738022: getBoundingClientRect reports double size for foreignObject children on a HiDPI monitor

报告的大小按devicePixelRatio缩放,在我的计算机上为1.5

,

这确实是Chrome中的错误。

这是Windows 10 chrome 80.0.3987.149(devicePixelRatio:2)上我的foreignObject大小。

windows

Mac chrome运作良好(devicePixelRatio:2): mac

本文链接:https://www.f2er.com/2456455.html

大家都在问