Skip to content

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

License

Notifications You must be signed in to change notification settings

kristerkari/css-viewport-units-transform

Repository files navigation

css-viewport-units-transform

Build Status Coverage Status Size contributions 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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published