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 🙏

© 2025 – Pkg Stats / Ryan Hefner

fitflex

v1.0.7

Published

CSS layout tool

Readme

Fitflex

Have you still been scratching your head about how to realize vertical-center alignment of DOM element? Don't worry, buddies. Fitflex provides you a comfortable method to realize responsive layout only by a few Javascript codes and configuration. One more thing, it can be adapted to all kinds of screen size of mobiles, pads, desktops… Are you thrilled about it? Let’s just play with it right now!

Play with Example

Click here to play with it

Download

npm install fitflex

Usage in browser

Script Tag

Find fitflex.js in folder of dist

  <script src="fitflex.js"></script>

Then let's configure options to adjust elements.

<body>
    <div id='box'>
        <div class='child'>child1</div>
        <div class='child'>child2</div>
        <div class='child'>child3</div>
    </div>
    <script src="fitflex.js"></script>
    <script>
        var option = {
          location:'vertical',
          center:'cross'
        }
        fit('#box').flex(option);
    </script>
</body>

Check your browser. see, vertical center!

Container

The container is the parentNode in which childNodes is placed by fitflex. It has the similar usage as jquery $("p").add("div").

Here it is.

fit(container).flex(option)

Options

 var option = {
            children: "",
            location: "",
            center: "",
            adjust: "",
            gapRatio: {
                left: 0,
                right: 0,
                top: 0,
                bottom: 0,
                outerAll: 0,
                innerWidth: 0,
                innerHeight: 0
            },
            screenWidth: { min: 0, max: Infinity },
            flexWhenResize: true
        };

| Key | Type | Value | | --------------- | -------------- | ----------------------------------------------------------------------------------------------------------- | | children | String |Array | selected childNodes | | location | String | horizontal, vertical | | center | String | forward, cross, bothway | | adjust | String | three strings combination: oneline|multiline + outerfit|innerfit + forward|cross|bothway. | | gapRatio | Object | keys: left, right, top, bottom, outerall, innerWidth, innerHeight | | screenWidth | Object | min: numbers, max: numbers |

Introduction to options

children

The selected childNodes involved into layout placement. By default, all childNodes will be involved. The value could be element ID or className, such as .child, #child , or array of them, ["child1"., ".child2", ".child3"] If you want to specify childNodes width and height, then [{d:.child1, w:0.1, height: 0.2}, {d:".child2", w:0.2, height: 0.1}] You even can use 2D array so that you can group childNodes into different rows, such as [[{d:".child1," w:0.1, h: 0.2}], [{d:".child2", w:0.2, h: 0.1}]]. pls note that w and h value is not px, it is the ratio of childNodes dimension to parentNode dimension.

location

horizontal(default) and vertical.

center

forward: childNodes centered in X-Axis; cross: centered in Y-Axis; bothway: centered in both X and Y Axis.

adjust

This option is used to adjust the fitting of childNodes bundaries and parentNodes bundaries so that you can make childNodes and parentNodes dimension fit each other automatically. Value setting is based on 3 strings combination, such as: onelineOuterfitForward or multilineInnerfitCross, case insensitive.

oneline: force selected childNodes into one line.

multiline: childNodes placement is based on previous options setting.

outerfit:adjust parentNodes bundaries to fit childNodes dimension.

innerfit:adjust childNodes bundaries to fit parentNodes dimension.

forward: fit in X-Axis.

cross: fit in Y-Axis.

bothway:fit in both X and Y Axis.

gapRatio

The gap distance between childNodes and parentNodes (left, right, top, bottom, outerall), or among childNodes (innerWidth, innerHeight). pls note that value is not px, it is the ratio of childNodes dimension to parentNode dimension. You can also set one or both as below

innerWidth: 'fit', innerHeight:`fit`

Then, the gap distance among childNode is largest so that outermost childNodes borders overlap with ParentNodes inner bundaris.

You also can do further fine tuning for each row or column gap distance among ChildNodes by setting array value.

innerWidth: [0.05, 0.03,...], innerHeight:[0.01, 0.02,...]

pls note that array cell value is the ratio of childNodes dimension to parentNode dimension.

screenWidth

fitflex is used for responsive layout, thus it is available to set the screen width range.

flexWhenResize

Adjust the layout when screen width is resized.

Responsive Layout

You can make different layouts adapted to different screen widths by using options array rather than one option.


<script>
        var opt1 = {
            location:'vertical',
            center:'cross',
            screenWidth: { min: 501, max: Infinity }
        }; 

        var opt2 = {
            location:'horizontal',
            center:'forward',
            screenWidth: { min: 0 , max: 500}
        };

        var optArray = [opt1, opt2]
        fit('#box').flex(optArray);
    </script>