因为刚开始没有思路,找了很多大神的参考,最初了解的出如下:
思路:在竖屏状态下,让body旋转成横屏,宽高获取屏幕的宽高;

<body><div id="print"><h3>Mlll000999887</h3></div></body>

css写法:

竖屏变横屏,body的宽高还是不对,当初用js来计算:

第二种办法:
1.通过增加监听事件onorientationchange,而后判断window.orientation这个参数

window.orientation参数对应的屏幕方向:Andriod:0 或180 横屏Andriod: 90 或 -90 竖屏ipad,iphone: 90 或 -90 横屏ipad,iphone: 0 或180 竖屏
  1. window.matchMedia("(orientation: portrait)") 办法
    返回的是一个MediaQueryList对象,matches值为true示意为竖屏,反之就是横屏:
安卓手机在某些浏览器中能够禁止页面横屏:QQ和微信中浏览器:<meta name="x5-orientation" content="portrait">UC浏览器:<meta name="screen-orientation" content="portrait">

最初:
当然不止这一种办法,也能够全靠css来实现;

最初感激博主大神:https://cloud.tencent.com/dev...
https://blog.csdn.net/Lc_styl...