为提升您的使用体验,本站正在维护,部分功能暂时无法使用。如果本站文章无法解决您的问题,您想要向社区提问的话,请到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 提问,我们的支持社区将会很快回复您的疑问。

搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

详细了解

Why might Responsive Design View disagree with the Box Model for the HTML element?

  • 5 个回答
  • 3 人有此问题
  • 3 次查看
  • 最后回复者为 jxxmxxj

more options

In the web page I'm writing right now, the Responsive Design View's width number doesn't match the width shown in the Box Model view (which means my media queries don't appear to be triggered at the correct width breakpoints). See the attached screenshot, which shows the page in RDV, the Box Model view, and a tooltip with the HTML element's dimensions.

I've not yet managed to reproduce this in a simpler page, though I'm still trying. I've ruled out the possible influence of inner iframes and the meta viewport tag.

So, I'd like to know what might cause the two tools to report different width figures.

Cheers, Jordan

In the web page I'm writing right now, the Responsive Design View's width number doesn't match the width shown in the Box Model view (which means my media queries don't appear to be triggered at the correct width breakpoints). See the attached screenshot, which shows the page in RDV, the Box Model view, and a tooltip with the HTML element's dimensions. I've not yet managed to reproduce this in a simpler page, though I'm still trying. I've ruled out the possible influence of inner iframes and the meta viewport tag. So, I'd like to know what might cause the two tools to report different width figures. Cheers, Jordan

被采纳的解决方案

jscher2000 said

Ah, I tested using 38.0.5. Could this be a zoom glitch?

D'oh! That was it! I was slightly zoomed-out, and after a Cmd+0, RDV now agrees exactly with the Box Model, and the media queries are behaving as they should.

Side note: The zoom was causing a second problem, since it was scaling a width of 430px to a number between 480px and 481px, triggering neither of my media queries (one of which had max-width: 480px, the other min-width: 481px). That was almost as puzzling as the numbers not matching in the first place.

Thanks again!

定位到答案原位置 👍 1

所有回复 (5)

more options

jxxmxxj said

See the attached screenshot, which shows the page in RDV, the Box Model view, and a tooltip with the HTML element's dimensions.

Whoops, seems the screenshot didn't attach. Let's try that again...

more options

If the body element is wider than html element, it can indicate a min-width or some other impediment to narrowing the body.

I'm not sure whether choosing a responsive design preset fires the resize event. If you drag the resizing handle on the right side one way or the other, does that make any difference?

more options

Thanks for your quick reply!

jscher2000 said

If the body element is wider than html element, it can indicate a min-width or some other impediment to narrowing the body.

Good idea. I suspect that something like that is going on, but I haven't nailed it down yet; the immediate sub-elements all have width specified either as a pixel count well below the window width, or as 100% (with zero padding, margin, and side border).

And I haven't set an element's min-width anywhere, period.

The width reported by the Inspector is consistently very close to 1.11667 times the width shown in Responsive Design View.

FWIW, I also just noticed that the little SVG logo (loaded via an IMG tag) I have in my navbar is similarly miscalculated; RDV shows 28.2388 and Inspector shows 31.5317 for its width (which is calculated by a preprocessor and specified in px in the resulting stylesheet).

I'm not sure whether choosing a responsive design preset fires the resize event. If you drag the resizing handle on the right side one way or the other, does that make any difference?

Yes, it's behaving consistently across all these ways of setting the width:

  • choosing presets
  • typing new widths in the preset box
  • dragging the right-hand resize handle
  • typing "resize to <W> <H>" in the Developer Toolbar

However, if I open the document in a new window via window.open() and then manipulate the resulting window via .resizeTo(), the breakpoints are all correct.

And, thoroughly confounding things, I just now tried it in my ordinary (non-Developer) install of Firefox (v38.0.5), and RDV behaves correctly there.

Any other thoughts?

由jxxmxxj于修改

more options

Ah, I tested using 38.0.5.

Could this be a zoom glitch?

more options

选择的解决方案

jscher2000 said

Ah, I tested using 38.0.5. Could this be a zoom glitch?

D'oh! That was it! I was slightly zoomed-out, and after a Cmd+0, RDV now agrees exactly with the Box Model, and the media queries are behaving as they should.

Side note: The zoom was causing a second problem, since it was scaling a width of 430px to a number between 480px and 481px, triggering neither of my media queries (one of which had max-width: 480px, the other min-width: 481px). That was almost as puzzling as the numbers not matching in the first place.

Thanks again!

由jxxmxxj于修改