Lighthouse audit says content not sized correctly for viewport, despite body width being 100%

George picture George · Nov 15, 2017 · Viewed 7.5k times · Source

I have set the body css of my html page to 100% and with no margins or padding, but it still does not pass the following Google Lighthouse audit "Content Sized Correctly for Viewport".

The audit passes if window.innerWidth === window.outerWidth

It says the viewport size is 422px whereas the window size is 412px, so this means the window is 10px wider than wanted.

When I inspect the body element, it is showing as being 412px wide.

I would like to pass this audit, any ideas of what is causing this?

Answer

uribalb picture uribalb · Jul 17, 2018

When you reveal the DevTools panel, it usually appears next to the main application page, which messes with the viewport size. I solved the problem by:

  • maximizing the browser window
  • docking the DevTools panel below the page