css-viewport-units-transform

    0.10.3 • Public • Published

    css-viewport-units-transform

    Build Status Build status Coverage Status Size PRs Welcome

    Transform CSS viewport units of a Javascript style object to pixels based on window dimensions.

    Supports vw, vh, vmin and vmax units.

    import { transform } from "css-viewport-units-transform";
    // or const transform = require("css-viewport-units-transform").transform;
     
    transform(
      {
        fontSize: "10vw"
      },
      {
        width: 480,
        height: 100
      }
    );

    ↓ ↓ ↓ ↓ ↓ ↓

    {
      fontSize: 48;
    }

    or

    transform(
      {
        myClass: {
          fontSize: "10vh"
        }
      },
      {
        width: 480,
        height: 100
      }
    );

    ↓ ↓ ↓ ↓ ↓ ↓

    {
      myClass: {
        fontSize: 10,
      }
    }

    Dependencies

    • None

    Install

    npm i css-viewport-units-transform

    DownloadsWeekly Downloads

    3,296

    Version

    0.10.3

    License

    MIT

    Unpacked Size

    7.95 kB

    Total Files

    5

    Last publish

    Collaborators

    • kristerkari