时间:2021-07-01 10:21:17 帮助过:21人阅读
你可以写不同的样式来区分电脑和移动端,利用js判断电脑或者移动端来加载不同的样式
你也可以单独分隔开来,电脑端和移动端文件分别在不同文件夹,然后通过判断来做url转向
例如
function fBrowserRedirect(){ var sUserAgent = navigator.userAgent.toLowerCase(); var bIsIpad = sUserAgent.match(/ipad/i) == "ipad"; var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os"; var bIsMidp = sUserAgent.match(/midp/i) == "midp"; var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4"; var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb"; var bIsAndroid = sUserAgent.match(/android/i) == "android"; var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce"; var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile"; if(bIsIpad){ var sUrl = location.href; if(!bForcepc){ window.location.href = "http://ipad.mail.163.com/"; //转向pad对应网址 } } if(bIsIphoneOs || bIsAndroid){ var sUrl = location.href; if(!bForcepc){ window.location.href = "http://smart.mail.163.com/"; //转向手机对应网址 } } if(bIsMidp||bIsUc7||bIsUc||bIsCE||bIsWM){ var sUrl = location.href; if(!bForcepc){ window.location.href = "http://m.mail.163.com/"; } } }
使用浮动或者使用css媒体查询来实现