Search code examples
cssphantomjsviewport-units

PhantomJS ignores fontsize in vw


I'd like to render a page with PhantomJS, and the font-size should be in VW, because I'd like to display the same page in different sizes.

Unfortunately, Phantomjs ignores font size in these units, no matter what I try.

ViewportSize is set in JS and also in HTML with meta tags.

PhantomJS vesion 1.9.7; win, linux, same result.


Solution

  • When you look at Viewport units: vw, vh, vmin, vmax at caniuse.com, you see that the earliest support for those units in Chrome was version 20. PhantomJS (1.9.7) is said to be equal in features to Chrome 13. So no, it's just not implemented.

    You might want to look at the polyfill. Execute it onInitialized or onLoadFinished inside of evaluate.

    If this does not help you, you might want to exchange PhantomJS for SlimerJS. It has the same API, but uses the Gecko engine that also powers Firefox. It is only headless in combination with xvfb-run.