Responsive Breakpoints

When making a responsive WordPress theme, it is good to be sure that I’m previewing the changes in my browser with the viewport at an appropriate size to show the changes I’m making in my code.

To make things easier when developing a site I add a few snippets of css into the stylesheet within the media queries section to add a transparent pseudo element before the html body which appears as an overlay at the top of the page.

The css required for this is very simple.

My first media query section in my stylesheet is headed

This tells me that the breakpoint is 1139px, so I add the following rules

The pixel value for the content rule should match the media query’s max-width.

The colors and background rules can be tweaked, I think it looks best with a transparent gradient, so I like to use the following:

The next breakpoint is 1023px, so I add a rule to change the content added in the previous rule within the next media query block:

Similar rules should be added for each size defined in a media query.

Once the site goes live these rules should be deleted.

A Plugin?

I am thinking of making a plugin to help streamline this, however I don’t think the media query values can easily be grabbed from the active theme’s stylesheet, so the sizes would need to be manually set in a plugin options page. Then, the additional CSS rules would be created in php and a function like

if (current_user_can('update_core'))

could be used to enable the responsive size indicator to only be seen by a logged-in admininstrator.