npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

postcss-px2viewport

v0.1.3

Published

A tool for PostCss

Downloads

17

Readme

postcss-px2viewport

一个postcss插件,结合viewport.js使用

默认使用vw作为布局单位,对于不支持vw单位的,则使用rem进行布局

对于标记了/*px*/的,则转换为[data-dpr="1"][data-dpr="2"][data-dpr="3"]三种不同的字体

对于标记了/*no*/的,则不做处理,依然使用px进行布局

how to use

webpack

please run npm install postcss-loader --save-dev, and add the code

var px2viewport = require('postcss-px2viewport');

module.exports = {
  module: {
    loaders: [
      {
        test: /\.css$/,
        loader: "style-loader!css-loader!postcss-loader"
      }
    ]
  },
  postcss: function() {
    return [px2viewport({viewportWidth: 750})];
  }
}
input
.class {
  border: 1px solid black;/*no*/
  margin-top: 0px;/*px*/
  font-size: 14px;/*px*/
  background-size: 30px 10px;
}
.class3,
.class4 {
  margin: 0px 20px;
  width: 750px;
  height: 100px;/*px*/
  font-size: 24px;/*px*/
}

@media (min-width: 750px) {
  .class3 {
    font-size: 16px;
    line-height: 22px;
  }
}
output
.class {
  border: 1px solid black;
  margin-top: 0;
  background-size: 4vw 1.3333333vw;
}
.class3,
.class4 {
  margin: 0px 2.6666667vw;
  width: 100vw;
}

@media (min-width: 100vw) {
  .class3 {
    font-size: 16px;
    line-height: 22px;
  }
}

[data-dpr="1"] .class {
  font-size: 7px;
}

[data-dpr="2"] .class {
  font-size: 14px;
}

[data-dpr="3"] .class {
  font-size: 21px;
}

[data-rem="true"] .class {
  background-size: 0.4rem 0.1333333rem;
}

[data-dpr="1"] .class3, [data-dpr="1"] .class4 {
  height: 50px;
  font-size: 12px;
}

[data-dpr="2"] .class3, [data-dpr="2"] .class4 {
  height: 100px;
  font-size: 24px;
}

[data-dpr="3"] .class3, [data-dpr="3"] .class4 {
  height: 150px;
  font-size: 36px;
}

[data-rem="true"] .class3, [data-rem="true"] .class4 {
  margin: 0px 0.2666667rem;
  width: 10rem;
}

Forbidden Rem or DPR

require('postcss-px2viewport')({
  viewportWidth: 750,
  baseDpr: 2,
  isDeleteRem: true,
  isDeleteDpr: true,
})
input
.item {
  float: left;
  width: 210px;
  height: 440px;
  margin-left: 30px;
}
.item-title {
  height: 48px;
  margin-top: 10px;
  line-height: 48px;
  font-size: 28px;/*px*/
  text-align: center;
  color: #494949;
}
output
.item {
  float: left;
  width: 28vw;
  height: 58.6666667vw;
  margin-left: 4vw;
}
.item-title {
  height: 6.4vw;
  margin-top: 1.3333333vw;
  line-height: 6.4vw;
  font-size: 14px;
  text-align: center;
  color: #494949;
}

license

MIT