3

I've half solved this issue, but without fully understanding the problem, which worries me. I wonder if someone can help me understand what is at play?

I have an iframe set to 100% width via CSS. The container div is 767px. And therefore so is the iframe.

I have the following media query in the iframe's stylesheet:

@media (max-width: 767px) {
    body {
        background: red;
    }
}

In all popular browsers tested other than Firefox, the media query takes effect and sets the body background to red. In Firefox, the media query only takes effect when the iframe is set to 766px - 1px less even though max-width should be 'up to and including'. This seems like a bug. My workaround for now is to set the iframe width to 766.7px (subtract .3 pixels). This seems to work in Firefox (subtracting 0.2 didn't work).

My question - what is going on here? Could this actually be a bug in Firefox? I know my iframe implementation is a little irregular, but I think the root cause may relate to this question which inspired my solution: Media query lost in Firefox when window resized to max-width minus scrollbar width

Community
  • 1
  • 1
Sebastian
  • 61
  • 4
  • hmm interesting! did you try to find if a bug like this already exists in bugzilla? – Praveen Puglia Feb 11 '15 at 09:59
  • I wasn't aware of bugzilla but I've submitted a bug report. I'll write back here with any additional information I receive/learn. Many thanks for responding! – Sebastian Feb 12 '15 at 10:12
  • There are same bugs now for FF and Chrome for me. I fixed it for now with `max-width: 767.8px` and styles for `767px` applies to this width. – gdfgdfg Aug 20 '17 at 19:04

2 Answers2

1

FWIW, identical behavior on Chrome was due to... the tab's browser zoom setting being set to 125% instead of 100%

I believe this threw off the calculation of a phone-simulating iframe within which should have been under the threshold at 767px.

I spent an hour diffing all the sources against an older deployment before noticing >_>

mstrange
  • 609
  • 7
  • 13
1

I experienced the same issue. I don't have Zoom set in my browser, but I do have a 2K Monitor and use the Display custom scaling provided by the Windows 10 OS, which I believe is causing the weird behavior in both FF and Chrome.

To fix, try to set layout.css.devPixelsPerPx to 1.0 (default is -1) on the about:config page to see if that has effect.

If necessary you can adjust its value in 0.1 or 0.05 steps (1.1 or 0.9) until icons or text look right.

Daniel Congrove
  • 3,519
  • 2
  • 35
  • 59