$ yarn add @astii/autofit
//entry of app
import { autoFit, autoScale } from "@astii/autofit";
autoScale({ dw: 375 });
//entry of app
import { autoFit, autoScale } from "@astii/autofit";
autoFit({ dw: 375, dh: 667 });
"px" need convert to "vw" and "vh"
.card {
/* width: 300px;
height: 300px; */
width: calc(300 * var(--pxw));
height: calc(300 * var(--pxh));
}
"px" need convert to "rem"
.card {
/* width: 300px;
height: 300px; */
width: calc(300 / var(--rem));
height: calc(300 / var(--rem));
}
Name | Type | Default | Description |
---|---|---|---|
dw | number | - | design width |
dh | number | window.innerHeight(viewport mode default to 100) | design height |
fitType | "viewport" | "rem" | "viewport" | autoFit type |
MIT