Git Product home page Git Product logo

pxtovw's Introduction

pxtovw

px convert vw 将px 转成 vw

  -w, --viewportWidth [value]', 'set `vw` unit value (default: 750)'
  -o, --output [path]", "the output file dirname")
  -p, --vwPrecision [value]', 'set vw value precision (default: 6)'
  -u, --unitToConvert [value]", "set need to convert unit (default: 'px')"
  -m, --minPixelValue [value]", "mix convert px value (default: 1)"
  -w, --viewportWidth [value]', '设置视窗宽度 (默认: 750)'
  -o, --output [path]", "设置输出路径")
  -p, --vwPrecision [value]', '设置转换为vw 的保留小数位数 (default: 6)'
  -u, --unitToConvert [value]", "设置需要转换的单位 (default: 'px')"
  -m, --minPixelValue [value]", "最小转换数值 (default: 1)"

API

const Pxtovw = require("../pxtovw");
const config = {
  viewportWidth: 750,
  unitPrecision: 6,
  unitToConvert: "px",
  minPixelValue: 1,
};

const pxtovwIns = new Pxtovw(config);
const vwCssText = pxtovwIns.converPxToVw('.....')

use cli

npm install pxtovw -g
pxtovw [filename].css -w 750 -o ./out -p 6 -u px -m 1

Example

input test css file test.css

.testcase {
  height: 100px;
  width: 100px;
  border-radius: 20px;
  padding: 10px 10px 10px!important;
  margin: 10px;
  font-size: 16px;
  background-color: bisque;
}

cli

pxtovw test.css -o ./

output css file test.vw.css

.testcase {
  height: 13.333333vw;
  width: 13.333333vw;
  border-radius: 2.666667vw;
  padding: 1.333333vw 1.333333vw 1.333333vw!important;
  margin: 1.333333vw;
  font-size: 2.133333vw;
  background-color: bisque;
}

Calculation

// height 100px
//cover vw keep 6  precision
const vwHeight = (100/750)*100 //13.333333

pxtovw's People

Contributors

flonny avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.