mui图片响应式全屏自适应方法含代码
.mui-content{position: absolute;
width: 100%;
height: 100%;
background: url(images/welcome_bg.jpg)no-repeat;
background-size: 100%100%;
}
有输入框时不要将height设为100%(弹出输入法会压缩页面,难看),应为固定值HTML的height为逻辑分辨率,手机有个物理分辨率,魅族手机:物理=逻辑*3采用沉浸式状态栏采用沉浸式状态栏
mui.plusReady(function() {
var height1 = plus.android.invoke(plus.android.currentWebview(), "getHeight");//高度物理分辨率
var height2 = plus.screen.resolutionHeight;//高度逻辑分辨率
var top = plus.navigator.getStatusbarHeight();//状态栏高度
document.getElementsByClassName("mui-content").style.height = (height2) + "px";
console.log(height1);//1920
console.log(height2);//640
console.log(top);//22
});
不采用沉浸式状态栏
mui.plusReady(function() {
var height1 = plus.android.invoke(plus.android.currentWebview(), "getHeight");//高度物理分辨率
var height2 = plus.screen.resolutionHeight;//高度逻辑分辨率
var top = plus.navigator.getStatusbarHeight();//状态栏高度
document.getElementsByClassName("mui-content").style.height = (height2-top) + "px";
console.log(height1);//1920
console.log(height2);//640
console.log(top);//22
});
版权声明:本文为CSDN博主「m0_37986841」的原创文章,
原文链接:https://blog.csdn.net/m0_37986841/article/details/78496292
页:
[1]