Chris Yeung
Chris Yeung

Reputation: 2723

Why is there an offset in media queries?

I was using Bourbon Neat to create some responsive layouts. However, I found out that the media query that I use was offset by around 70px.. I set a breakpoint of 640px for tablets (as shown in the CSS inspector

CSS inspection

However, when i try to adjust the screen, chrome tells me that the media query is only applied when the window is at ~580px... I was very confused why this is and i have no idea where the problem may lie.

Thanks for helping!

Upvotes: 0

Views: 1020

Answers (1)

LoveAndCoding
LoveAndCoding

Reputation: 7947

For pixel based media queries, zooming in and out can cause them to break at different points. Instead of using pixel based values, if you use em or rem, you can have a bit more control if the user does decide to zoom. When they zoom, the text will change size, which can cause the breakpoints to activate (and make sure your layout doesn't look odd).

Note that converting to ems should be pretty easy. The value of em in pixels is equal to the font-size value of the element in question (in this case the root) in pixels. By default this will be 16px, so dividing your values by 16 should get you an approximation of your em value.

Upvotes: 2

Related Questions