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-rpx2vmin

v0.0.1

Published

小程序rpx转换为vmin

Downloads

5

Readme

postcss-rpx2vmin

将rpx单位转换为vmin

vmax 相对于视口的宽度或高度中较大的那个。其中最大的那个被均分为100单位的vmax vmin 相对于视口的宽度或高度中较小的那个。其中最小的那个被均分为100单位的vmin 为了适配PC端的样式,在这里我们只用到了vmin。 小程序PC端展示样式就相当于将竖屏改为横屏 当我们在竖屏时候,100vmin的取值为手机屏幕宽度,当横屏时候,100vmin的取值仍然为手机屏幕宽度,所以以vmin为单位的元素,在手机屏幕发生旋转的时候,其显示大小并不会发生改变(毕竟不管横屏竖屏,100vmin都等于屏幕的宽度)。 在使用rpx进行布局时,750rpx的取值为手机屏幕的宽度,而在使用vmin时,100vmin的取值为手机屏幕的宽度,所以,rpx和vmin之间存在一个换算关系,即:x rpx=( x * 100 / 750)vmin。举个例子,75rpx转化为vmin为75 * 100 / 750 = 10 vmin。所以,我们只要将rpx转化成vmin就可以愉快的码页面了~

// test.js
const css = `
  .container {
    width: 750rpx;
    height: 400rpx;
    font-size: 32rpx;
  }
`;

postcss([rpxToVminPlugin()])
  .process(css)
  .then(result => {
    console.log(result.css);
  });

使用

在postcss.config.js里使用

module.exports = {
  plugins: [
    require('postcss')(),
    require('postcss-rpx2vmin')(), // 引用插件并调用
  ],
};