Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simple same-height columns to the grid with flexbox #11851

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions _includes/nav-css.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<li><a href="#grid-nesting">Nesting columns</a></li>
<li><a href="#grid-column-ordering">Column ordering</a></li>
<li><a href="#grid-less">LESS mixins and variables</a></li>
<li><a href="#grid-same-height-columns">Same height columns</a></li>
</ul>
</li>
<li>
Expand Down
23 changes: 23 additions & 0 deletions css.html
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,29 @@ <h4>Example usage</h4>
</div>
{% endhighlight %}

<h3 id="grid-same-height-columns">Same height columns</h3>
<p>Give your grid columns the same heights using responsive classes on the row, such as <code>.row-md-flex</code>.</p>

<p>Note that this is not supported in Internet Explorer prior to version 10. In any unsupported browser, the <code>row-*-flex</code> classes will have no effect.</p>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should probably be made a callout box


<p>Add the <code>.row-md-flex</code> class to a row. All of the columns will stretch vertically to occupy the same height as the tallest column.</p>

<div class="row show-grid row-md-flex">
<div class="col-md-4">.row-md-flex > .col-md-4</div>
<div class="col-md-4">.row-md-flex > .col-md-4<br/>taller<br/>column</div>
<div class="col-md-4">.row-md-flex > .col-md-4</div>
</div>

{% highlight html %}
<div class="row row-md-flex">
<div class="col-md-4">.row-md-flex > .col-md-4</div>
<div class="col-md-4">.row-md-flex > .col-md-4<br/>taller<br/>column</div>
<div class="col-md-4">.row-md-flex > .col-md-4</div>
</div>
{% endhighlight %}

<p>If you specify more than 12 columns in one row, the <code>.row-*-flex</code> classes will force them to shrink into a single row, and the columns will not wrap.</p>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should probably be moved before the example, where the rest of the description is. May or may not need to be a callout.


</div>


Expand Down
30 changes: 30 additions & 0 deletions dist/css/bootstrap.css
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,36 @@ pre code {
margin-right: -15px;
margin-left: -15px;
}
.row-xs-flex {
display: flex;
Copy link
Contributor

Choose a reason for hiding this comment

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

You should call display-flex() instead of inlining the properties.

display: -webkit-flex;
display: -moz-flex;
display: -ms-flexbox;
}
@media (min-width: 768px) {
.row-sm-flex {
display: flex;
display: -webkit-flex;
display: -moz-flex;
display: -ms-flexbox;
}
}
@media (min-width: 992px) {
.row-md-flex {
display: flex;
display: -webkit-flex;
display: -moz-flex;
display: -ms-flexbox;
}
}
@media (min-width: 1200px) {
.row-lg-flex {
display: flex;
display: -webkit-flex;
display: -moz-flex;
display: -ms-flexbox;
}
}
.col-xs-1, .col-sm-1, .col-md-1, .col-lg-1, .col-xs-2, .col-sm-2, .col-md-2, .col-lg-2, .col-xs-3, .col-sm-3, .col-md-3, .col-lg-3, .col-xs-4, .col-sm-4, .col-md-4, .col-lg-4, .col-xs-5, .col-sm-5, .col-md-5, .col-lg-5, .col-xs-6, .col-sm-6, .col-md-6, .col-lg-6, .col-xs-7, .col-sm-7, .col-md-7, .col-lg-7, .col-xs-8, .col-sm-8, .col-md-8, .col-lg-8, .col-xs-9, .col-sm-9, .col-md-9, .col-lg-9, .col-xs-10, .col-sm-10, .col-md-10, .col-lg-10, .col-xs-11, .col-sm-11, .col-md-11, .col-lg-11, .col-xs-12, .col-sm-12, .col-md-12, .col-lg-12 {
position: relative;
min-height: 1px;
Expand Down
2 changes: 1 addition & 1 deletion dist/css/bootstrap.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/grid/grid.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ h4 {
hr {
margin-top: 40px;
margin-bottom: 40px;
}
}
9 changes: 9 additions & 0 deletions examples/grid/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ <h3>Offset, push, and pull resets</h3>
<div class="col-sm-6 col-md-5 col-md-offset-2 col-lg-6 col-lg-offset-0">.col-sm-6 .col-md-5 .col-md-offset-2 .col-lg-6 .col-lg-offset-0</div>
</div>

<hr>

<h3>Same-height columns</h3>
<p>Make columns in a row the same height using flexbox.</p>
<div class="row row-xs-flex">
<div class="col-xs-6 col-xs-flex">.col-xs-6</div>
<div class="col-xs-6 col-xs-flex">.col-xs-6<br/><br/>(nb. the row has the <code>.row-xs-flex</code> class as well as <code>.row</code>)</div>
</div>


</div> <!-- /container -->

Expand Down
23 changes: 23 additions & 0 deletions less/grid.less
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,29 @@
.make-row();
}

// Flexbox rows
//
// Used for same-height grid columns
.row-xs-flex {
.display-flex();
}
@media (min-width: @screen-sm) {
.row-sm-flex {
.display-flex();
}
}
@media (min-width: @screen-md) {
.row-md-flex {
.display-flex();
}
}
@media (min-width: @screen-lg) {
.row-lg-flex {
.display-flex();
}
}



// Columns
//
Expand Down
8 changes: 7 additions & 1 deletion less/mixins.less
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,13 @@
filter: ~"alpha(opacity=@{opacity-ie})";
}


// Flexbox
.display-flex() {
display: flex;
display: -webkit-flex;
display: -moz-flex;
display: -ms-flexbox;
}

// GRADIENTS
// --------------------------------------------------
Expand Down