标签:
手机浏览器对header有时用position:fixed;没用,只能用position:absolute;代替,鉴于此,封装了如下代码用于适配和过滤:
function isSupportFixed() { var userAgent = window.navigator.userAgent, ios = userAgent.match(/(iPad|iPhone|iPod)\s+OS\s([\d_\.]+)/), ios5below = ios && ios[2] && (parseInt(ios[2].replace(/_/g, ‘.‘), 10) < 5), operaMini = /Opera Mini/i.test(userAgent), body = document.body, div, isFixed; div = document.createElement(‘div‘); div.style.cssText = ‘display:none;position:fixed;z-index:100;‘; body.appendChild(div); isFixed = window.getComputedStyle(div).position != ‘fixed‘; body.removeChild(div); div = null; return !!(isFixed || ios5below || operaMini); }
201508061040_《移动开发之——解决header定位差异问题代码》
标签:
原文地址:http://www.cnblogs.com/beesky520/p/4707314.html