Both .container
and .container-fluid
are responsive (i.e. they change the layout based on the screen width), but in different ways (I know, the naming doesn't make it sound that way).
Short Answer:
.container
is jumpy / choppy resizing, and
.container-fluid
is continuous / fine resizing at width: 100%.
From a functionality perspective:
.container-fluid
continuously resizes as you change the width of your window/browser by any amount, leaving no extra empty space on the sides ever, unlike how .container
does. (Hence the naming: "fluid" as opposed to "digital", "discrete", "chunked", or "quantized").
.container
resizes in chunks at several certain widths. In other words, it will be different specific aka "fixed" widths different ranges of screen widths.
Semantics: "fixed width"
You can see how naming confusion can arise. Technically, we can say .container
is "fixed width", but it is fixed only in the sense that it doesn't resize at every granular width. It's actually not "fixed" in the sense that it's always stays at a specific pixel width, since it actually can change size.
From a fundamental perspective:
.container-fluid
has the CSS property width: 100%;
, so it continually readjusts at every screen width granularity.
.container-fluid {
width: 100%;
}
.container
has something like "width = 800px" (or em, rem etc.), a specific pixel width value at different screen widths. This of course is what causes the element width to abruptly jump to a different width when the screen width crosses a screen width threshold. And that threshold is governed by CSS3 media queries, which allow you to apply different styles for different conditions, such as screen width ranges.
@media screen and (max-width: 400px){
.container {
width: 123px;
}
}
@media screen and (min-width: 401px) and (max-width: 800px){
.container {
width: 456px;
}
}
@media screen and (min-width: 801px){
.container {
width: 789px;
}
}
Beyond
You can make any fixed widths element responsive via media queries, not just .container
elements, since media queries is exactly how .container
is implemented by bootstrap in the background (see JKillian's answer for the code).