I am playing with bootstraps v2.3.2 now. media queries (I do not use a bootstrap grid, only these 4 media queries) to test them on mobile and tablet devices, and I notice that I continue to receive a horizontal scroll bar, and I donβt understand why?
Basically, I have one div and this CSS:
html { box-sizing: border-box; } *, *:before, *:after { box-sizing: inherit; } body{ margin:0; height: 300px; } div{ padding: 0 10px; margin: 0 auto; background: aqua; width: 980px; border: 1px solid black; height: 100%; } @media (min-width: 1200px) { div{ background: red; width: 1200px; } } @media (min-width: 768px) and (max-width: 979px) { div{ background: yellow; width: 768px; } } @media (max-width: 767px) { div{ background: blue; width: 100%; } } @media (max-width: 480px) { div{ background: green; } }
The situation when I click the vertical scrollbar: JSBin
But when I do not force the vertical scrollbar, I get the desired result: JSBin
Thus, this is evident thanks to the vertical scrollbar. I found this article about the scroll problem in Recurrent Web Design, but I get the same result in both Chrome and FF.
Update : how to watch bootstrap v3.3.2 source . I noticed that they have new media queries, however they do not use the minimum possible width for .container . These are their media queries:
@media (min-width: 768px) { .container { width: 750px; } } @media (min-width: 992px) { .container { width: 970px; } } @media (min-width: 1200px) { .container { width: 1170px; } }
And here is JSBin . Even when I made the vertical scrollbar appear, it will not cause the horizontal scrollbar.
But if I want to use the minimum possible width for media queries, for example:
@media (min-width: 768px) { .container { width: 768px; } } @media (min-width: 992px) { .container { width: 992px; } } @media (min-width: 1200px) { .container { width: 1200px; } }
This will call horizontal scrollbar - JSBin
Did the bootstrap guys do it on purpose, because there might be a vertical scrollbar?
Question Why can't I use the smallest possible width in a media query when there is a vertical scrollbar?
I know this may be a newbie, but I would appreciate it if someone clarified this for me.