为什么元素检查器将此 div 显示为具有非零宽度?

Why does the element inspector show this div as having non-zero width?

在Chrome DevTools的代码部分,我们可以看到div的"width"属性设置为0px。但是在实际中window,悬停在上面,看起来实际宽度还是400像素。

为什么?

请注意,有问题的 div#raphContainer2(注意 2),不是 Chrome 中以蓝色突出显示的那个开发工具。

因为 width 不是您的 div 的有效属性,它应该嵌入 style

您的代码:

<div id="raphContainer2" style="display" width="0px">

应该怎样:

<div id="raphContainer2" style="display: block; width:0px">