New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

mpx2rem

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mpx2rem

mini px to rem

latest
Source
npmnpm
Version
1.0.4
Version published
Maintainers
1
Created
Source

mpx2rem

A mini px to rem library.

npm version GitHub license npm

Installation

Run npm i mpx2rem.

Usage

require('mpx2rem');

or

<script src="./../lib/mpx2rem.min.js"></script>

or you can copy index.min.js into your HTML template, like:

<script>var mpx2rem=function(e){var t=e.document.documentElement,n=e.devicePixelRatio,i=null;function o(){var e,i=t.getBoundingClientRect().width;1===n&&(i=720),i>720&&(i=720),e=i/7.2,t.style.fontSize=e+"px"}n=n>2?3:n>1?2:1,t.setAttribute("data-dpr",n),e.addEventListener("resize",function(){clearTimeout(i),i=setTimeout(o,200)},!1),o()}(window);</script>

Example

The design is measured at @X2 720px wide. Dealing with SASS or LESS like:

/* SCSS @X2 */
$px: (1/100)+rem;
div {
  width: 200*$px;
  height: 200*$px;
}

If the design is measured at @X3 1080px wide.

/* SCSS @X3 */
$px3: (1/150)+rem;
div {
  width: 300*$px;
  height: 300*$px;
}

Compiled into css:

div {
  width: 1rem;
  height: 1rem;
}

In the end, the html is :

img

License

MIT

Keywords

px

FAQs

Package last updated on 26 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts