style-unit
style-unit
Last updated 7 years ago by yuanyan .
BSD-3-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ npm install style-unit 
SYNC missed versions from official npm registry.

style-unit

Unit conversion for calculating dimensional css attributes, especially for rpx.

API

convertUnit(value, prop, platform);

Property Type Required Description
value string/number true
prop string true
platform string false Auto assignment with universal-env, different platforms have different rpx conversion. Details are as follows.

Web

In Web, Calculate rpx to vw (relative to viewport width 750).

750rpx -> 100vw

setViewportWidth

You can use setViewportWidth method update viewport width

setViewportWidth(1500);

750rpx -> 50vw

Weex

In Weex, Calculate rpx to px (viewport width is 750).

750rpx -> 750px

setRpx

You can use setRpx method update coefficient of 750

setRpx(1500 / 750)

750rpx -> 1500px

MiniApp

rpx (responsive pixel): Adaptable to the screen width in MiniApp. The specified screen width is 750 rpx. If the screen width on iPhone6 is 375 px (750 physical pixels), then 750 rpx = 375 px = 750 physical pixels, i.e. 1 rpx = 0.5 px = 1 physical pixel.

Node.js

Use Weex result:

convertUnit('500rpx', 'width', 'weex')

Use Web result:

convertUnit('500rpx', 'width', 'web')

Current Tags

  • 1.0.4                                ...           1_x (5 years ago)
  • 3.0.1-0                                ...           beta (4 years ago)
  • 3.0.5                                ...           latest (2 years ago)

65 Versions

  • 3.0.5                                ...           2 years ago
  • 3.0.4                                ...           3 years ago
  • 3.0.3                                ...           3 years ago
  • 3.0.2                                ...           4 years ago
  • 3.0.1                                ...           4 years ago
  • 3.0.1-0                                ...           4 years ago
  • 3.0.0                                ...           4 years ago
  • 2.0.1                                ...           5 years ago
  • 1.0.4                                ...           5 years ago
  • 1.0.3                                ...           5 years ago
  • 2.0.0                                ...           5 years ago
  • 2.0.0-0                                ...           5 years ago
  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.1-0                                ...           5 years ago
  • 1.0.0                                ...           6 years ago
  • 0.6.6-0                                ...           6 years ago
  • 0.6.5                                ...           6 years ago
  • 0.6.4                                ...           6 years ago
  • 0.6.3-1                                ...           6 years ago
  • 0.6.3                                ...           7 years ago
  • 0.6.2                                ...           7 years ago
  • 0.6.1                                ...           7 years ago
  • 0.6.0                                ...           7 years ago
  • 0.5.4                                ...           7 years ago
  • 0.5.2                                ...           7 years ago
  • 0.5.1                                ...           7 years ago
  • 0.5.0                                ...           7 years ago
  • 0.4.20                                ...           7 years ago
  • 0.4.19                                ...           7 years ago
  • 0.4.18                                ...           7 years ago
  • 0.4.17                                ...           7 years ago
  • 0.4.16                                ...           7 years ago
  • 0.4.15                                ...           7 years ago
  • 0.5.0-beta                                ...           7 years ago
  • 0.4.14                                ...           7 years ago
  • 0.4.13                                ...           7 years ago
  • 0.4.12                                ...           7 years ago
  • 0.4.11                                ...           7 years ago
  • 0.4.10                                ...           7 years ago
  • 0.4.9                                ...           7 years ago
  • 0.4.8                                ...           7 years ago
  • 0.4.7                                ...           7 years ago
  • 0.4.6                                ...           7 years ago
  • 0.4.5                                ...           7 years ago
  • 0.4.4                                ...           7 years ago
  • 0.4.3                                ...           7 years ago
  • 0.4.2                                ...           7 years ago
  • 0.4.1                                ...           7 years ago
  • 0.4.0                                ...           7 years ago
  • 0.3.8                                ...           7 years ago
  • 0.3.7                                ...           7 years ago
  • 0.3.6                                ...           7 years ago
  • 0.3.5                                ...           7 years ago
  • 0.3.4                                ...           7 years ago
  • 0.3.3                                ...           8 years ago
  • 0.3.2                                ...           8 years ago
  • 0.3.1                                ...           8 years ago
  • 0.3.0                                ...           8 years ago
  • 0.2.11                                ...           8 years ago
  • 0.2.10                                ...           8 years ago
  • 0.2.9                                ...           8 years ago
  • 0.2.8                                ...           8 years ago
  • 0.2.7                                ...           8 years ago
  • 0.2.6                                ...           8 years ago
Maintainers (1)
Downloads
Total 5
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (0)
None

© 2010 - cnpmjs.org x YWFE | Home | YWFE