JSFiddle - React, Tailwind, and code Playground
HTML
<meta name="viewport" content="width=device-width,initial-scale=1.0">
JavaScript
function doOnOrientationChange() {
var viewportmeta = document.querySelector('meta[name="viewport"]');
switch(window.orientation)
{
case -90:
case 90:
alert('landscape'); // Just for debug obviously
viewportmeta.content = 'initial-scale=0.6';
break;
default:
alert('portrait'); // Just for debug obviously
viewportmeta.content = 'initial-scale=0.8';
break;
}
}
// Only bind the event on iPhone and iPad so we do not try and do this on any other device.
if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i)) {
window.addEventListener('orientationchange', doOnOrientationChange);
// Initial execution if needed
doOnOrientationChange();
}