首页 > 经验记录 > html根据手机屏幕大小做自适应

html根据手机屏幕大小做自适应

弹框宽高自适应,核心代码

var isMobile = {
    Android: function () {
        return navigator.userAgent.match(/Android/i) ? true : false;
    },
    BlackBerry: function () {
        return navigator.userAgent.match(/BlackBerry/i) ? true : false;
    },
    iOS: function () {
        return navigator.userAgent.match(/iPhone|iPad|iPod/i) ? true : false;
    },
    Windows: function () {
        return navigator.userAgent.match(/IEMobile/i) ? true : false;
    },
    any: function () {
        return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Windows());
    }
};
var clientWidth =  document.body.clientWidth;//浏览器视图宽度
var clientHeight =  document.body.clientHeight;//浏览器视图高度
function textAdvertising() {
    var width = "630px";
    var height = "700px";
    if (isMobile.any()) {
        width = clientWidth-50+"px";
        height = clientHeight-100+"px";
    }
    ......

 

           


CAPTCHAis initialing...
EA PLAYER &

历史记录 [ 注意:部分数据仅限于当前浏览器 ]清空

      00:00/00:00