npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

flexgrid.css

v1.2.0

Published

Flexgrid is a responsive, declarative grid system powered by flexbox.

Downloads

4

Readme

flexgrid.css

A responsive, declarative grid system powered by flexbox. Demo at flexgrid.axiomzen.co

NPM

Dependencies

Flexgrid.css is a responsive, declarative grid system powered by flexbox. It allows you to generate finely tuned responsive layouts at a lightning pace. The declarative nature lets you determine what size a grid cell should be at a certain screen width.

Installation

There are two ways to use flexgrid.css:

  • Use it as an npm module by running the following command:

    npm install flexgrid.css --save
  • Download the files directly:

Usage

Grids can de used on generic HTML elements such as div, but resets are also in place to use them on ul and ol.

Defaults

If you're using it out of the box, these are the default values that come shipped:

  • columns: 12
  • breakpoints:
    • xs: 320px
    • sm: 480px
    • md: 640px
    • lg: 760px
    • xl: 1020px
    • xx: 1200px
  • gutters:
    • xs: 0.2rem
    • sm: 0.32rem
    • md: 0.52rem
    • lg: 0.84rem
    • xl: 1.36rem
    • xx: 2.2rem

These are all easily customisable if you build the file yourself.

Basic Usage

In the most basic form, you can create a grid where all cells occupy an equal amount of space:

<div class="Grid">
  <div class="Grid-cell"></div>
  <div class="Grid-cell"></div>
  ...
</div>

If you want cells to occupy the amount of space that their content takes up, then use the --auto modifier:

<div class="Grid">
  <div class="Grid-cell--auto"></div>
  <div class="Grid-cell--auto"></div>
  <div class="Grid-cell--auto"></div>
  <div class="Grid-cell--auto"></div>
  ...
</div>

Responsive, Declarative Usage

In order to declaratively build a responsive grid in which cells occupy a certain percentage of width at a certain screen size, you can chain together size modifiers for the cells. When using this approach, the bare requirement is to declare the cell size at the smallest screen size, i.e. xs. The other sizes are optional. Here are all screen size modifiers:

  • xs
  • sm
  • md
  • lg
  • xl
  • xx

The grid is based on a 12 column layout, so when thinking about your display for one row, think that the span number must add up to 12. Here's a basic example:

<ul class="Grid">
  <li class="Grid-cell--xs-2"></li>
  <li class="Grid-cell--xs-8"></li>
  <li class="Grid-cell--xs-2"></li>
</ul>

This grid will display cells the same at any screen size, in a 2:8:2 ratio (compared to the number of columns, 12). Let's make these grid cells change at various breakpoints:

<div class="Grid">
  <div class="Grid-cell--xs-4 Grid-cell--md-3 Grid-cell--lg-2"></div>
  <div class="Grid-cell--xs-4 Grid-cell--md-3 Grid-cell--lg-2"></div>
  <div class="Grid-cell--xs-4 Grid-cell--md-3 Grid-cell--lg-2"></div>
  <div class="Grid-cell--xs-4 Grid-cell--md-3 Grid-cell--lg-2"></div>
  <div class="Grid-cell--xs-4 Grid-cell--md-3 Grid-cell--lg-2"></div>
  <div class="Grid-cell--xs-4 Grid-cell--md-3 Grid-cell--lg-2"></div>
  <div class="Grid-cell--xs-4 Grid-cell--md-3 Grid-cell--lg-2"></div>
  <div class="Grid-cell--xs-4 Grid-cell--md-3 Grid-cell--lg-2"></div>
  <div class="Grid-cell--xs-4 Grid-cell--md-3 Grid-cell--lg-2"></div>
  <div class="Grid-cell--xs-4 Grid-cell--md-3 Grid-cell--lg-2"></div>
  <div class="Grid-cell--xs-4 Grid-cell--md-3 Grid-cell--lg-2"></div>
  <div class="Grid-cell--xs-4 Grid-cell--md-3 Grid-cell--lg-2"></div>
</div>

In the above example, the cells will be in a ratio of 4:4:4 per row, making 4 rows in total, by default and at the xs screen size. At the md screen size, they will occupy 3:3:3:3 per row, making 3 rows in total. Finally at the lg screen size, they will occupy 2:2:2:2:2:2 per row, making 2 rows in total. If you're afraid about cell rows not always adding up to the number 12, fear not. Extra cells just overflow to a new line.

Offsetting Cells

If at any point in time you want to offset cells, there's a simple way to do just that. In the following example, the first cell will span 12 columns at xs screens, and 6 columns at md screens. It will also be offset by 6 columns on md screens. The second cell will conform to the flow of the first one, and sit below it because it can't fit in the first row:

<div class="Grid Grid--gutter-xl">
  <div class="Grid-cell--xs-12 Grid-cell--md-6 Grid-cell--md-offset-6"></div>
  <div class="Grid-cell--xs-12 Grid-cell--md-8"></div>
</div>

If at any point you want to reset the offset to 0, you can just use the offset-0 addition to the modifier:

<div class="Grid Grid--gutter-xl">
  <div class="Grid-cell--xs-12 Grid-cell--md-6 Grid-cell--md-offset-6 Grid-cell--xl-offset-0"></div>
  <div class="Grid-cell--xs-12 Grid-cell--md-8"></div>
</div>

It's important to be careful that your offsets + cell spans don't overflow outside the rows...a little bit of very basic math is required!

Adding Gutters

You can add gutters to the grid cells which will create an even, fixed horizontal and vertical spacing between cells, while collapsing the excess amounts. Gutter modifiers come in four sizes:

<div class="Grid Grid--gutter-sm">...</div>
<div class="Grid Grid--gutter-md">...</div>
<div class="Grid Grid--gutter-lg">...</div>
<div class="Grid Grid--gutter-xl">...</div>

Orientation and Spacing

To change the orientation to a columnar grid, add the following modifier:

<div class="Grid Grid--column">...</div>

To change the alignment of grid cells with respect to the flex line, use the following modifiers:

<!-- aligns to start of flex line -->
<div class="Grid Grid--alignStart">...</div>

<!-- aligns to end of flex line -->
<div class="Grid Grid--alignEnd">...</div>

<!-- aligns to center of flex line -->
<div class="Grid Grid--alignCenter">...</div>

To change the spatial distribution of grid cells along the main axis, use the following modifiers:

<!-- packs cells to center of main axis -->
<div class="Grid Grid--justifyCenter">...</div>

<!-- packs cells to end of main axis -->
<div class="Grid Grid--justifyEnd">...</div>

<!-- distributes extra space evenly between cells -->
<div class="Grid Grid--spaceBetween">...</div>

<!-- distributes extra space evenly around cells -->
<div class="Grid Grid--spaceAround">...</div>

Browser Support

This component has been tested in the following browsers:

| Browser | Version | | ------- | ------- | | Chrome | Chrome 46.0+ | | Firefox | Firefox 40.0+ | | Safari | Safari 9.0+ | | Opera | Opera 33.0+ |

Contributing

Please check CONTRIBUTING.md.

This project adheres to the Open Code of Conduct. By participating, you are expected to honor this code.

Author

Collaborators

License

MIT