flex-object
CSS layout module based on flexbox
Last updated 10 years ago by jxnblk .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install flex-object 
SYNC missed versions from official npm registry.

The flex-object is a powerful suite of utilities based on the flexible box layout module. These utilities can replace the need for a grid system in many instances, but can also be combined with the Basscss grid for even more possibilities.

Note: browser support for the flexible box layout module is limited. See http://caniuse.com/#feat=flexbox

.flex

To begin, add the .flex class to a parent element. This sets the element to display: flex and enables a flex context for all direct child elements.

<div class="flex">
  <div class="p1 border">Hamburger</div>
  <div class="p1 border">Hamburger</div>
</div>

.flex-wrap

To wrap elements, use the .flex-wrap utility.

<div class="flex flex-wrap">
  <div class="p1 border">Hamburger</div>
  <div class="p1 border">Hamburger</div>
  <div class="p1 border">Hamburger</div>
  <div class="p1 border">Hamburger</div>
  <div class="p1 border">Hamburger</div>
  <div class="p1 border">Hamburger</div>
  <div class="p1 border">Hamburger</div>
  <div class="p1 border">Hamburger</div>
  <div class="p1 border">Hamburger</div>
  <div class="p1 border">Hamburger</div>
  <div class="p1 border">Hamburger</div>
  <div class="p1 border">Hamburger</div>
</div>

.flex-column

To arrange items vertically, use the .flex-column utility.

<div class="flex flex-column">
  <div class="p1 border">Hamburger</div>
  <div class="p1 border">Hamburger</div>
  <div class="p1 border">Hamburger</div>
</div>

Alignment

Use these utilities to control vertical alignment of child elements.

.flex-center

To vertically center child elements, add the .flex-center class to the parent element.

<div class="flex flex-center">
  <div class="flex-auto px2 py4 blue border">
    <h1 class="m0">Hamburger</h1>
  </div>
  <div class="px2 blue border">Hot dog</div>
</div>

.flex-stretch

To stretch all elements to fill the height of the parent, use the .flex-stretch utility.

<div class="flex flex-stretch">
  <div class="flex-auto px2 py4 blue border">
    <h1 class="m0">Hamburger</h1>
  </div>
  <div class="px2 blue border">Hot dog</div>
</div>

.flex-stretch with nested content

To ensure nested elements stretch as well, add the .flex class to relevant elements.

<div class="flex flex-stretch">
  <div class="flex-auto px2 py4 blue border">
    <h1 class="m0">Hamburger</h1>
  </div>
  <div class="flex blue border">
    <div class="px2 white bg-blue">
      Hot dog
    </div>
  </div>
</div>

.flex-baseline

To align child elements to their baseline, use the .flex-baseline utility.

<div class="flex flex-baseline blue border-bottom">
  <div class="flex-auto px2">
    <h1 class="m0">Hamburger</h1>
  </div>
  <div class="px2">Hot dog</div>
</div>

.flex-start

To align child elements to the top, use the .flex-start utility.

<div class="flex flex-start blue border-top">
  <div class="flex-auto px2">
    <h1 class="m0">Hamburger</h1>
  </div>
  <div class="px2">Hot dog</div>
</div>

.flex-end

To align child elements to the bottom, use the .flex-end utility.

<div class="flex flex-end blue border-bottom">
  <div class="flex-auto px2">
    <h1 class="m0">Hamburger</h1>
  </div>
  <div class="px2">Hot dog</div>
</div>

Justify

To automatically fill the space between child elements, use .flex-justify.

<div class="flex flex-justify">
  <div class="p1 border">Burger</div>
  <div class="p1 border">Burger</div>
  <div class="p1 py1 border">Burger</div>
</div>

Responsive Utilities

To set display flex only at certain breakpoints and up, use the breakpoint-prefixed versions of .flex. All other utilities will only work at the set breakpoint.

<div class="sm-flex flex-center mb2 blue">
  <div class="p1 border">
    <h2 class="m0">.sm-flex</h2>
  </div>
  <div class="flex-auto p1 border">Hamburger</div>
  <div class="p1 border">Hamburger</div>
</div>
<div class="md-flex flex-center mb2 blue">
  <div class="p1 border">
    <h2 class="m0">.md-flex</h2>
  </div>
  <div class="flex-auto p1 border">Hamburger</div>
  <div class="p1 border">Hamburger</div>
</div>
<div class="lg-flex flex-center mb2 blue">
  <div class="p1 border">
    <h2 class="m0">.lg-flex</h2>
  </div>
  <div class="flex-auto p1 border">Hamburger</div>
  <div class="p1 border">Hamburger</div>
</div>

Child elements

To control the size and behavior of child elements, use these utilities.

.flex-auto

To make an element grow or shrink as needed, use the .flex-auto utility.

<div class="flex">
  <div class="px2 py1 border">Hamburger</div>
  <div class="px2 py1 border">Hamburger</div>
  <div class="flex-auto blue border"></div>
  <div class="px2 py1 border">Hamburger</div>
</div>

.flex-grow

To make an element grow, but not shrink, use the .flex-grow utility.

<div class="flex">
  <div class="px2 py1 border">Hamburger</div>
  <div class="px2 py1 border">Hamburger</div>
  <div class="flex-grow blue border"></div>
  <div class="px2 py1 border">Hamburger</div>
</div>

.flex-none

To prevent an element from growing or shrinking, use the .flex-none utility.

<div class="flex">
  <div class="flex-auto px2 py1 border">Hamburger</div>
  <div class="flex-auto px2 py1 border">Hamburger</div>
  <div class="flex-none px2 py1 border">Hamburger</div>
</div>

Ordering

To change the order of child elements, use the .flex-first and .flex-last utilities.

.flex-first

<div class="flex">
  <div class="px2 py1 border">Hamburger</div>
  <div class="flex-first px2 py1 border">First Hamburger</div>
  <div class="px2 py1 border">Hamburger</div>
</div>

.flex-last

<div class="flex">
  <div class="px2 py1 border">Hamburger</div>
  <div class="flex-last px2 py1 border">Last Hamburger</div>
  <div class="px2 py1 border">Hamburger</div>
</div>

Parent Element Utilities

.flex          { display: flex }
.flex-column   { flex-direction: column }
.flex-wrap     { flex-wrap: wrap }
.flex-center   { align-items: center }
.flex-baseline { align-items: baseline }
.flex-stretch  { align-items: stretch }
.flex-start    { align-items: flex-start }
.flex-end      { align-items: flex-end }

Child Element Utilities

.flex-first { order: -1 }
.flex-last  { order: 1024 }
.flex-auto  { flex: 1 1 auto }
.flex-grow  { flex: 1 0 auto }
.flex-none  { flex: none }

Current Tags

  • 2.0.0-beta.2                                ...           beta (9 years ago)
  • 2.0.5                                ...           latest (9 years ago)

26 Versions

  • 2.0.5                                ...           9 years ago
  • 2.0.4                                ...           9 years ago
  • 2.0.3                                ...           9 years ago
  • 2.0.2                                ...           9 years ago
  • 2.0.1                                ...           9 years ago
  • 2.0.0                                ...           9 years ago
  • 2.0.0-beta.2                                ...           9 years ago
  • 2.0.0-beta.1                                ...           9 years ago
  • 2.0.0-beta.0                                ...           9 years ago
  • 1.1.3                                ...           10 years ago
  • 1.1.2                                ...           10 years ago
  • 1.1.1                                ...           10 years ago
  • 1.1.0                                ...           10 years ago
  • 1.0.8                                ...           10 years ago
  • 1.0.7                                ...           10 years ago
  • 1.0.6                                ...           10 years ago
  • 1.0.5                                ...           10 years ago
  • 1.0.4                                ...           10 years ago
  • 1.0.3                                ...           10 years ago
  • 1.0.2                                ...           10 years ago
  • 1.0.1                                ...           10 years ago
  • 1.0.0                                ...           10 years ago
  • 0.0.4                                ...           10 years ago
  • 0.0.3                                ...           10 years ago
  • 0.0.2                                ...           10 years ago
  • 0.0.1                                ...           10 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (8)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE