移动端屏幕简单适配

CSS


-------------------------------------------------

    


JavaScript

(function(){
            var h = window.innerHeight;
            var w = window.innerWidth;
            console.log('h:'+h+',w:'+w);
            if(h>w)
                console.log('竖屏');
            else
                console.log('横屏');
            console.log(navigator.userAgent);
            if(/Android|webOS|iPhone|iPad|BlackBerry/i.test(navigator.userAgent)){
                console.log('移动端');
                var d =document.getElementsByClassName('ptag2')[0];
                d.innerHTML = d.innerHTML+'移动端
'; } else{ console.log('PC端'); var d =document.getElementsByClassName('ptag2')[0]; d.innerHTML = d.innerHTML+'PC端
'; } })();

你可能感兴趣的:(移动端屏幕简单适配)