to-px

WebJar for to-px

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

to-px
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

to-px
WebJar for to-px
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/mikolalysenko/to-px

Download to-px

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/to-px/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>to-px</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/to-px/
implementation 'org.webjars.npm:to-px:1.1.0'
// https://jarcasting.com/artifacts/org.webjars.npm/to-px/
implementation ("org.webjars.npm:to-px:1.1.0")
'org.webjars.npm:to-px:jar:1.1.0'
<dependency org="org.webjars.npm" name="to-px" rev="1.1.0">
  <artifact name="to-px" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='to-px', version='1.1.0')
)
libraryDependencies += "org.webjars.npm" % "to-px" % "1.1.0"
[org.webjars.npm/to-px "1.1.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : parse-unit jar [1.0.1,2)

Project Modules

There are no modules declared in this project.

to-px

Get the scale factor to convert any CSS unit to px (logical pixel units).

testling badge

Example

var toPX = require('to-px')

console.log(toPX('1em'))
console.log(toPX('.23vh'))
console.log(toPX('in'))

Install

Note that this module only works within the DOM.

npm i to-px

API

var scaleFactor = require('to-px')(unit[, element])

Computes the number of pixels in the unit string.

  • unit is a CSS unit type or a number followed by CSS unit, eg vh or 2in
  • element is an optional element in which the unit is computed (default is document.body)

Returns The number of pixels in the unit

Note Conversions for % are not supported since they are context dependent.

License

(c) 2015 Mikola Lysenko. MIT License

Versions

Version
1.1.0
1.0.1