Skip to content

Commit

Permalink
Add .container-fluid variation for full-width containers and layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
mdo committed Dec 8, 2013
1 parent 73bc7d9 commit 6273604
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 17 deletions.
1 change: 1 addition & 0 deletions _includes/nav-css.html
Expand Up @@ -16,6 +16,7 @@
<li><a href="#grid-media-queries">Media queries</a></li>
<li><a href="#grid-options">Grid options</a></li>
<li><a href="#grid-example-basic">Ex: Stacked-to-horizonal</a></li>
<li><a href="#grid-example-fluid">Ex: Fluid container</a></li>
<li><a href="#grid-example-mixed">Ex: Mobile and desktops</a></li>
<li><a href="#grid-example-mixed-complete">Ex: Mobile, tablet, desktops</a></li>
<li><a href="#grid-responsive-resets">Responsive column resets</a></li>
Expand Down
12 changes: 11 additions & 1 deletion css.html
Expand Up @@ -76,7 +76,7 @@ <h1 id="grid">Grid system</h1>
<h3 id="grid-intro">Introduction</h3>
<p>Grid systems are used for creating page layouts through a series of rows and columns that house your content. Here's how the Bootstrap grid system works:</p>
<ul>
<li>Rows must be placed within a <code>.container</code> for proper alignment and padding.</li>
<li>Rows must be placed within a <code>.container</code> (fixed-width) or <code>.container-fluid</code> (full-width) for proper alignment and padding.</li>
<li>Use rows to create horizontal groups of columns.</li>
<li>Content should be placed within columns, and only columns may be immediate children of rows.</li>
<li>Predefined grid classes like <code>.row</code> and <code>.col-xs-4</code> are available for quickly making grid layouts. LESS mixins can also be used for more semantic layouts.</li>
Expand Down Expand Up @@ -249,6 +249,16 @@ <h3 id="grid-example-basic">Example: Stacked-to-horizontal</h3>
<div class="col-md-6">.col-md-6</div>
<div class="col-md-6">.col-md-6</div>
</div>
{% endhighlight %}

<h3 id="grid-example-fluid">Example: Fluid container</h3>
<p>Turn any fixed-width grid layout into a full-width layout by changing your outermost <code>.container</code> to <code>.container-fluid</code>.</p>
{% highlight html %}
<div class="container-fluid">
<div class="row">
...
</div>
</div>
{% endhighlight %}

<h3 id="grid-example-mixed">Example: Mobile and desktop</h3>
Expand Down
38 changes: 35 additions & 3 deletions dist/css/bootstrap.css
Expand Up @@ -839,6 +839,33 @@ pre code {
}
}

.container-fluid {
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
margin-left: auto;
}

.container-fluid:before,
.container-fluid:after {
display: table;
content: " ";
}

.container-fluid:after {
clear: both;
}

.container-fluid:before,
.container-fluid:after {
display: table;
content: " ";
}

.container-fluid:after {
clear: both;
}

.row {
margin-right: -15px;
margin-left: -15px;
Expand Down Expand Up @@ -4467,14 +4494,18 @@ textarea.input-group-sm > .input-group-btn > .btn {
}

.container > .navbar-header,
.container > .navbar-collapse {
.container-fluid > .navbar-header,
.container > .navbar-collapse,
.container-fluid > .navbar-collapse {
margin-right: -15px;
margin-left: -15px;
}

@media (min-width: 768px) {
.container > .navbar-header,
.container > .navbar-collapse {
.container-fluid > .navbar-header,
.container > .navbar-collapse,
.container-fluid > .navbar-collapse {
margin-right: 0;
margin-left: 0;
}
Expand Down Expand Up @@ -4530,7 +4561,8 @@ textarea.input-group-sm > .input-group-btn > .btn {
}

@media (min-width: 768px) {
.navbar > .container .navbar-brand {
.navbar > .container .navbar-brand,
.navbar > .container-fluid .navbar-brand {
margin-left: -15px;
}
}
Expand Down
2 changes: 1 addition & 1 deletion dist/css/bootstrap.min.css

Large diffs are not rendered by default.

27 changes: 24 additions & 3 deletions less/grid.less
Expand Up @@ -2,7 +2,11 @@
// Grid system
// --------------------------------------------------

// Set the container width, and override it for fixed navbars in media queries

// Container widths
//
// Set the container width, and override it for fixed navbars in media queries.

.container {
.container-fixed();

Expand All @@ -17,12 +21,30 @@
}
}

// mobile first defaults

// Fluid container
//
// Utilizes the mixin meant for fixed width containers, but without any defined
// width for fluid, full width layouts.

.container-fluid {
.container-fixed();
}


// Row
//
// Rows contain and clear the floats of your columns.

.row {
.make-row();
}


// Columns
//
// Common styles for small and large grid columns

.make-grid-columns();


Expand Down Expand Up @@ -76,4 +98,3 @@
.make-grid(@grid-columns, lg, push);
.make-grid(@grid-columns, lg, offset);
}

22 changes: 13 additions & 9 deletions less/navbar.less
Expand Up @@ -93,14 +93,17 @@
//
// When a container is present, change the behavior of the header and collapse.

.container > .navbar-header,
.container > .navbar-collapse {
margin-right: -@navbar-padding-horizontal;
margin-left: -@navbar-padding-horizontal;

@media (min-width: @grid-float-breakpoint) {
margin-right: 0;
margin-left: 0;
.container,
.container-fluid {
> .navbar-header,
> .navbar-collapse {
margin-right: -@navbar-padding-horizontal;
margin-left: -@navbar-padding-horizontal;

@media (min-width: @grid-float-breakpoint) {
margin-right: 0;
margin-left: 0;
}
}
}

Expand Down Expand Up @@ -159,7 +162,8 @@
}

@media (min-width: @grid-float-breakpoint) {
.navbar > .container & {
.navbar > .container &,
.navbar > .container-fluid & {
margin-left: -@navbar-padding-horizontal;
}
}
Expand Down

1 comment on commit 6273604

@zlatanvasovic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forget to update docs about .container-fluid drop.

Please sign in to comment.