v-center: table display method

view source

Vertically center descendent elements with the display: table method.

use-name
scut-vcenter-td
type
mixin, with default-values placeholder
arguments
  1. $inner
    default
    ".scut-inner"

    A CSS selector for the inner element. Can be a single selector or a comma-separated list of selectors. In either case, wrap selectors in quotes.

This method requires a container and an inner element. The mixin applies to the container; identify the to-be-centered inner element(s) with the $inner argument.

Any to-be-centered element should be an immediate child of the container (container > inner).

example

HTML

<div class="eg-vcenter-td eg-vcenter-td-1">  <span class="scut-inner">
    Using the default classname "scut-inner".
  </span>
</div>
<div class="eg-vcenter-td eg-vcenter-td-2">
  <div class="eg-vcenter-td-inner">
    Using a special classname.
  </div>
</div>
<p>And illustrating the use of a list of distinct selectors ...</p>
<div class="eg-vcenter-td eg-vcenter-td-3">
  <div class="special-selector-1">first</div>
  <div class="special-selector-2">second</div>
  <div class="special-selector-3">third</div>
</div>

SCSS

.eg-vcenter-td-1 {
  @include scut-vcenter-td;
  // or @extend %scut-vcenter-td;
  height: 8em;
}
.eg-vcenter-td-2 {
  @include scut-vcenter-td(".eg-vcenter-td-inner");
  height: 12em;
}
// illustrating a list of selectors
.eg-vcenter-td-3 {
  @include scut-vcenter-td(".special-selector-1", ".special-selector-2", ".special-selector-3");
  height: 9em;
}

Result

Using the default classname "scut-inner".
Using a special classname.

And illustrating the use of a list of distinct selectors ...

first
second
third