Reputation: 551
EDIT: I am completely rewriting this question because I don't think I was being clear enough in my original posting.
According to bootstrap's website, the browser widths for each category of column should be as follows:
// Extra small devices (portrait phones, less than 576px)
// No media query since this is the default in Bootstrap
// Small devices (landscape phones, 576px and up)
@media (min-width: 576px) { ... }
// Medium devices (tablets, 768px and up)
@media (min-width: 768px) { ... }
// Large devices (desktops, 992px and up)
@media (min-width: 992px) { ... }
// Extra large devices (large desktops, 1200px and up)
@media (min-width: 1200px) { ... }
// Extra small devices (portrait phones, less than 576px)
@media (max-width: 575px) { ... }
// Small devices (landscape phones, less than 768px)
@media (max-width: 767px) { ... }
// Medium devices (tablets, less than 992px)
@media (max-width: 991px) { ... }
// Large devices (desktops, less than 1200px)
@media (max-width: 1199px) { ... }
// Extra large devices (large desktops)
// No media query since the extra-large breakpoint has no upper bound on its width
In summary: col-xl is 1200 pixels and up, lg is between 992-1199, md is 768-991, sm is 576-768, and xs is up to 575.
My problem is that for some reason, my webpage is behaving as if xs is sm, sm is md, md is lg, and lg is xl.
View this codepen in the google chrome inspector: https://codepen.io/colesam/full/YxjVwW/
There should be three items per row in lg and up, sm and md should be 2 per row, and xs should be 1.
See below in two examples:
EDIT 2: My header includes the following meta tag:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
EDIT 3: I have now tried inspecting the page on two separate computers but I am getting the same result. I also updated Bootstrap but to no avail. I'm really quite baffled as to why this would be happening. I tried adding xl columns to the html and no matter how large the screen size, the xl columns would not activate.
Here is an image of the google chrome inspector tool. It shows that .col-md-* is activated even though we are within the bounds for lg columns:
Upvotes: 3
Views: 10764
Reputation: 1
<style>
body{
background: #007bff;
}
@media screen and (min-width: 576px){
body{
background: #007bff;
}
}
@media screen and (min-width: 768px) {
body{
background: #dc3545;
}
}
@media screen and (min-width: 992px) {
body{
background: #28a745;
}
}
@media screen and (min-width: 1200px) {
body{
background: 6f42c1;
}
}
</style>
Upvotes: 0
Reputation: 551
It turns out I was looking at the breakpoints for Bootstrap v4+ when I have been using version 3.3.7.
For Bootstrap 4 all of the breakpoints were shifted to make room for col-xl-*.
The Bootstrap 3 breakpoints are:
/* Extra Small Devices, Phones */
@media only screen and (min-width : 480px) {
}
/* Small Devices, Tablets */
@media only screen and (min-width : 768px) {
}
/* Medium Devices, Desktops */
@media only screen and (min-width : 992px) {
}
/* Large Devices, Wide Screens */
@media only screen and (min-width : 1200px) {
}
Upvotes: 1
Reputation: 350
Bootstrap is mobile-first, so there's
.col-xs-*
@media (min-width: 768px) {
.col-sm-*
}
@media (min-width: 992px) {
.col-md-*
}
@media (min-width: 1200px) {
.col-lg-*
}
for grid (col-*) classes instead of
@media (max-width: 575px) { ... }
@media (max-width: 767px) { ... }
@media (max-width: 991px) { ... }
@media (max-width: 1199px) { ... }
Upvotes: 1