viewport-sizer
v1.2.3
Published
A package to set the viewport for browser/website.
Downloads
270
Maintainers
Readme
Viewport Sizer
Simple plugin for auto resizing the browser viewport for the website in Desktop mode.
Install
npm
npm i viewport-sizer
Resize viewport automatically.
var { resize } = require('viewport-sizer');
resize();
Set the viewport width manually
var { resize } = require('viewport-sizer');
resize({width:1920});
Set the viewport height manually
var { resize } = require('viewport-sizer');
resize({height:1080});
Set both widht and height of the viewport manually
var { resize } = require('viewport-sizer');
resize({width:1500, height:900});
Add below css variable in root
:root {
--custom-vw:100vw;
--custom-vh:100vh;
}
Following css change must be done
1. Replace `100vh` with `var(--custom-vh)`
1. Replace `100vw` with `var(--custom-vw)`
Example
replace
body {
width:100vw;
height:100vh;
}
with
body {
width:var(--custom-vw);
height:var(--custom-vh);
}
Note: CSS replacement must be done at all the place.