ios和安卓,虚拟键盘前者是同级后者有的不是同级导致。
参考:https://blog.csdn.net/w001yy/article/details/108777106
1 通过动态设置viewport的height值,使页面在软键盘弹起时仍能正常显示,避免因可视窗口高度改变而导致的页面布局问题。
<meta name="viewport" id="viewportMeta">
2
var initViewport = function(height){
var metaEl = document.querySelector("#viewportMeta");
var content = "height=" + height + ",width=device-width,initial-scale=1.0,user-scalable=no";
metaEl.setAttribute('name', 'viewport');
metaEl.setAttribute('content', content);
}
var realHeight = window.innerWidth > window.innerHeight ? window.innerWidth : window.innerHeight;
initViewport(realHeight);