One thing that I quickly noticed when we started building responsive websites was that we were constantly resizing our browsers. We would resize the browser to the largest media query, and then step down and watch the changes so we knew what media query we were looking at. This is not a good way to design a website. I figured that if we had a tool that would show us exactly what size the viewport was, we would know what media queries would be active. Taking it one step further, I thought why shouldn't the tool just tell me which media query just fired?
So, I wrote this little bookmarklet. It parses the included CSS files of the current page and creates an array of media query declarations. It then sets up listeners using the matchMedia method to trigger events when media queries change.
mediaQuery Bookmarklet (drag this to your bookmarks bar)
The page dimensions should work in any modern browser. Media query display is supported in:
- Chrome 9+
- Safari 5.1.5
- iOS 5.1.1
6/26/12 Version 1.3 Updates
- No longer displays duplicate media queries
- “Close” button added to remove element from display
- Toggle added to move element from right-hand to left-hand of display