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

v2 - Utilities-Vertical Alignment: rebuild and responsive rework #105

Merged
merged 1 commit into from
Nov 10, 2016
Merged
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 docs/_data/nav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
- title: Sizing & Positioning
- title: Spacing
- title: Typography
- title: Vertical Alignment

- title: Widgets
pages:
Expand Down
36 changes: 0 additions & 36 deletions docs/utilities/sizing-positioning.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,39 +46,3 @@ The `.position-f-t` class can be used to easily position elements at the top of
z-index: $zindex-navbar-fixed;
}
{% endhighlight %}

## Vertical Row Alignment

Give some vertical alignment, using `display: table;` to keep items in a full width row. Child items need to be defined with `.valign-item` in order to receive alignment.

{% example html %}
<div class="valign-top">
<div class="valign-item">
<a href="#">View more in teacher's guide</a> |
<a href="#">Common Core alignment</a>
</div>
<div class="valign-item text-right">
<button type="button" class="btn btn-primary btn-lg">Continue</button>
</div>
</div>

<div class="valign-middle">
<div class="valign-item">
<a href="#">View more in teacher's guide</a> |
<a href="#">Common Core alignment</a>
</div>
<div class="valign-item text-right">
<button type="button" class="btn btn-primary btn-lg">Continue</button>
</div>
</div>

<div class="valign-bottom">
<div class="valign-item">
<a href="#">View more in teacher's guide</a> |
<a href="#">Common Core alignment</a>
</div>
<div class="valign-item text-right">
<button type="button" class="btn btn-primary btn-lg">Continue</button>
</div>
</div>
{% endexample %}
68 changes: 68 additions & 0 deletions docs/utilities/vertical-alignment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
layout: docs
title: Vertical Alignment
group: utilities
---

Give some vertical alignment to elements by manipulating their [`vertical-align` property](https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align).

Note that only items with the following display properties can be vertically aligned:
- inline
- inline-block
- inline-table
- table-cell

The alignments consist of the items in the following list and are also available in responsive variants. Please refer to how our [breakpoint nomenclature]({{ site.baseurl }}/layout/overview/#breakpoint-nomenclature) is used.
- `.valign-baseline`
- `.valign-top`
- `.valign-middle`
- `.valign-bottom`
- `.valign-text-top`
- `.valign-text-bottom`

Example with inline elements.

{% example html %}
<div class="bg-gray-50">
<span class="bg-cyan-100 valign-baseline">baseline</span>
-
<span class="bg-cyan-100 valign-top">top</span>
-
<span class="bg-cyan-100 valign-middle">middle</span>
-
<span class="bg-cyan-100 valign-bottom">bottom</span>
-
<span class="bg-cyan-100 valign-text-top">text-top</span>
-
<span class="bg-cyan-100 valign-text-bottom">text-bottom</span>
</div>
{% endexample %}

Using table cells.

{% example html %}
<table class="table table-bordered" style="height: 100px;">
<tbody>
<td class="valign-baseline">baseline</td>
<td class="valign-top">top</td>
<td class="valign-middle">middle</td>
<td class="valign-bottom">bottom</td>
<td class="valign-text-top">text-top</td>
<td class="valign-text-bottom">text-bottom</td>
</tbody>
</table>
{% endexample %}

Slightly more complex uses, such as being able to align items in a row, become quick and easy.

{% example html %}
<div class="bg-gray-50 width-100 display-table">
<div class="display-table-cell valign-bottom">
<a href="#">View more in teacher's guide</a> |
<a href="#">Common Core alignment</a>
</div>
<div class="display-table-cell valign-bottom text-right">
<button type="button" class="btn btn-primary btn-lg">Continue</button>
</div>
</div>
{% endexample %}
35 changes: 9 additions & 26 deletions scss/utilities/_valign.scss
Original file line number Diff line number Diff line change
@@ -1,31 +1,14 @@
// scss-lint:disable ImportantRule

// Vertical row alignments
.valign-top,
.valign-middle,
.valign-bottom {
display: table;
width: 100%;
}
@each $breakpoint in map-keys($grid-breakpoints) {
$bprule: breakpoint-designator($breakpoint);

.valign-top {
> .valign-item {
display: table-cell;
float: none !important;
vertical-align: top;
}
}
.valign-middle {
> .valign-item {
display: table-cell;
float: none !important;
vertical-align: middle;
}
}
.valign-bottom {
> .valign-item {
display: table-cell;
float: none !important;
vertical-align: bottom;
@include media-breakpoint-up($breakpoint) {
.valign#{$bprule}-baseline { vertical-align: baseline !important; }
.valign#{$bprule}-top { vertical-align: top !important; }
.valign#{$bprule}-middle { vertical-align: middle !important; }
.valign#{$bprule}-bottom { vertical-align: bottom !important; }
.valign#{$bprule}-text-bottom { vertical-align: text-bottom !important; }
.valign#{$bprule}-text-top { vertical-align: text-top !important; }
}
}