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

@fdmediagroep/css-grid

v2.0.51

Published

FDMG CSS Grid with Flexbox fallback

Downloads

115

Readme

Build Publish CodeQL Bundle-size minified+gzip NPM

fdmg-css-grid

FDMG CSS Grid with Flexbox fallback. Gap-size is 1rem.

Installation

  • npm i --save @fdmg/css-grid

Import as CSS Module

Import both if you need FlexBox fallback otherwise only include the Grid.

  • Grid: import '@fdmg/css-grid/css/grid.css';
  • FlexBox: import '@fdmg/css-grid/css/flex.css';

Usage

Set default size in your project

To maximize accessabilty there is no default (font) size set as we want to use the browsers' default default size. Setting the root font-size in your project to 62.5% will result in 1rem = 10px. Then define your font-size for your project (i.e.) as 1.6rem for 16px. This will ensure proper scaling of units.

Full-width column

<div class="grid">
    <div class="xs-12 s-12 m-12 l-12 xl-12">
        Takes full width regardless of screen width
    </div>
</div>

Full-width columns as rows

<div class="grid">
    <div class="xs-12 s-12 m-12 l-12 xl-12 gap-bottom">
        Takes full width regardless of screen width and adds a gap below
    </div>
    <div class="xs-12 s-12 m-12 l-12 xl-12">Place below previous column</div>
</div>

Responsive columns

In case your browser doesn't support CSS Grid you may still want to have a gap between the columns. In the example below you can see gap-3 is added as CSS class. With this you're telling the Grid that there are 3 gaps in the widest view. It will know what to do when the screen becomes smaller and the responsive system kicks in.

<div class="grid">
    <div class="xs-12 s-12 m-6 l-4 xl-3 gap-3">
        1/4th on xl, 1/3 on l, 1/2 on m and full width on smaller
    </div>
    <div class="xs-12 s-12 m-6 l-4 xl-3 gap-3">
        1/4th on xl, 1/3 on l, 1/2 on m and full width on smaller
    </div>
    <div class="xs-12 s-12 m-6 l-4 xl-3 gap-3">
        1/4th on xl, 1/3 on l, 1/2 on m and full width on smaller
    </div>
    <div class="xs-12 s-12 m-6 l-4 xl-3 gap-3">
        1/4th on xl, 1/3 on l, 1/2 on m and full width on smaller
    </div>
</div>

Nested grid

<div class="grid">
    <div class="xs-12 s-12 m-6 l-4 xl-3 gap-3 gap-bottom">
        1/4th on xl, 1/3 on l, 1/2 on m and full width on smaller
    </div>
    <div class="xs-12 s-12 m-6 l-4 xl-3 gap-3 gap-bottom">
        1/4th on xl, 1/3 on l, 1/2 on m and full width on smaller
    </div>
    <div class="xs-12 s-12 m-6 l-4 xl-3 gap-3 gap-bottom">
        1/4th on xl, 1/3 on l, 1/2 on m and full width on smaller
    </div>
    <div class="xs-12 s-12 m-6 l-4 xl-3 gap-3 gap-bottom grid">
        <div class="xs-12 s-12 m-6 l-4 xl-3 gap-3 gap-bottom">
            1/4th on xl, 1/3 on l, 1/2 on m and full width on smaller
        </div>
        <div class="xs-12 s-12 m-6 l-4 xl-3 gap-3 gap-bottom">
            1/4th on xl, 1/3 on l, 1/2 on m and full width on smaller
        </div>
        <div class="xs-12 s-12 m-6 l-4 xl-3 gap-3 gap-bottom">
            1/4th on xl, 1/3 on l, 1/2 on m and full width on smaller
        </div>
        <div class="xs-12 s-12 m-6 l-4 xl-3 gap-3 gap-bottom">
            1/4th on xl, 1/3 on l, 1/2 on m and full width on smaller
        </div>
    </div>
</div>

Advanced gap

Note that we declare a gap-3 which is used when 4 columns are shown next to each other. gap-2 will start its override when the last column turns full width.

<div class="grid">
    <div class="xs-12 s-12 m-4 l-4 xl-3 gap-2 gap-3 gap-bottom">
        1/4th on xl, 1/3 on l, m and s and full width on smaller
    </div>
    <div class="xs-12 s-12 m-4 l-4 xl-3 gap-2 gap-3 gap-bottom">
        1/4th on xl, 1/3 on l, m and s and full width on smaller
    </div>
    <div class="xs-12 s-12 m-4 l-4 xl-3 gap-2 gap-3 gap-bottom">
        1/4th on xl, 1/3 on l, m and s and full width on smaller
    </div>
    <div class="xs-12 s-12 m-12 l-12 xl-3 gap-3 gap-bottom">
        1/4th on xl, full width on smaller
    </div>
</div>
  • Note: the *gap* CSS classes are only necessary when using the FlexBox fallback.

Show & Hide CSS classes

You can show/hide elements for their respective screensizes using xs-hide, xs-show, s-hide and s-show etc. Special case xs-hide, hide-lt-m etc. will hide only for screen sizes with a max-width of XS, M etc. So it will not affect other screen sizes. For instance:

...
<div class="xs-12 xs-hide s-12">Will still show on screens larger than XS</div>
<div class="xs-12 hide-lt-m">Will not show on screens smaller than M.</div>
<div class="xs-12 hide-lt-l">Will not show on screens smaller than L.</div>
...

All other show/hide classes are calculated through min-width so will affect larger screen sizes. For instance:

...
<div class="xs-12 s-hide">Will not show on screens larger than XS</div>
<div class="xs-12 s-hide xl-show">
    Will not show on screens larger than XS and smaller than XL
</div>
<div class="xs-12 s-hide l-show">
    Will not show on screens larger than XS and smaller than L
</div>
...

Paddings/Margins system

There is a paddings/margins system in place which allows you to use fixed CSS classes to apply paddings/margins to elements. The naming convention is as follows <device size>__<padding|margin>[+-]<multiplier>. Each increment is +0.25rem. So if <device size>__<padding|margin>+1 is 0.25rem then <device size>__<padding|margin>+2 is 0.5rem and <device size>__m-1 is -0.25rem.

Example:

<div class="xs__m-0">sets margin to 0 for device sizes xs and up</div>

<div class="l__m+6">base margin multiplied by 6 for device sizes l and up</div>

<div class="xs__m-0 l__m+6">
    devices smaller than l will have margin 0 larger devices have a base margin
    multiplied by 6
</div>

<div class="xs__pt+5 xs__pr+5 xs__pb+5 xs__pl+5">
    padding-top, padding-right, padding-bottom, padding-left has base margin
    multiplied by 5
</div>
<div class="xs__p+5">base padding multiplied by 5</div>
<div class="xs__m-5">base margin multipled by -5</div>

Currently available paddings/margins multipliers

Paddings can't have negative values.

  • 0
  • -1/+1
  • -2/+2
  • -3/+3
  • -4/+4
  • -5/+5
  • -6/+6
  • -7/+7
  • -8/+8

Currently available paddings/margins directions

  • p: all paddings
  • pt: padding top
  • pr: padding right
  • pb: padding bottom
  • pl: padding left
  • m: all margins
  • mt: margin top
  • mr: margin right
  • mb: margin bottom
  • ml: margin left

Known issues

There are many issues regarding the FlexBox fallback. It does not mirror all features available with CSS Grid. One of such issues is the gap. When you want to implement a more advanced responsive layout I.e. 4 columns becomes 3 columns or even less and you want to hide the extraneous column then the gap space will not be shown correctly.

Build and run demo page

  1. npm install
  2. npm run dev
    • The demo will run on localhost:3000

Compile CSS

  1. npm run build:ci