当前位置: 首页 > news >正文

ios html css,IOS 7 - css - html height - 100% = 692px

可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):

问题:

I have a weird bug on iPad iOS7 landscape mode.

What i was able to investigate is that in iOS7 window.outerHeight is 692px and

window.innerHeight 672px; while in previous versions both values are 672px.

Even though my and

tags have height 100% there seems to be space for scrolling, and the weird thing is that this problem only shows up on landscpae

You can see what i am talking about by visiting t.cincodias.com, for example, in a iOS 7 iPad the footer bar (or the header sometimes) will be cut. But on previous iOS versions the content displays fine at fullscreen.

Even when i set the height of both tags to height: 672px !important and position:absolute; bottom: 0;, you can still scroll the content vertically by touching an iframe (the ads are iframes).

I'm running the release candidate version of iOS7

thanks for any help.

回答1:

I believe this is a bug in iOS 7 - if you rotate it to portrait mode, it sets both (innerHeight/outerHeight) to the same value. If it isn't a bug, then portrait mode has one because the behavior isn't consistent.

You could detect iOS 7/mobile Safari and use window.innerHeight if iOS 7.

回答2:

I used this JavaScript solution for solving that problem:

if (

navigator.userAgent.match(/iPad;.*CPU.*OS 7_\d/i) &&

window.innerHeight != document.documentElement.clientHeight

) {

var fixViewportHeight = function() {

document.documentElement.style.height = window.innerHeight + "px";

if (document.body.scrollTop !== 0) {

window.scrollTo(0, 0);

}

};

window.addEventListener("scroll", fixViewportHeight, false);

window.addEventListener("orientationchange", fixViewportHeight, false);

fixViewportHeight();

document.body.style.webkitTransform = "translate3d(0,0,0)";

}

回答3:

I'll combine the answers. Thanks all!

You can do something like this:

if (navigator.userAgent.match(/iPad;.*CPU.*OS 7_\d/i)) {

$('#yourDivID').height(window.innerHeight);

window.scrollTo(0, 0);

}

The window.scrollTo solves the issue of the bar overlapping in landscape when rotating.

Cheers!

回答4:

I reproduce the same problem in iOS 8.

Here is my solution.

I listened resize, scroll, orientationChange event, to ensure when user trigger screen size change, will call reset height function.

I wrote a debounce to prevent multiple call.

And It's in a closure and no dependent (no jQuery).

(function(){

var setViewportHeight = (function(){

function debounced(){

document.documentElement.style.height = window.innerHeight + "px";

if (document.body.scrollTop !== 0) {

window.scrollTo(0, 0);

}

}

var cancelable = null;

return function(){

cancelable && clearTimeout(cancelable);

cancelable = setTimeout(debounced, 100);

};

})();

//ipad safari

if(/iPad/.test(navigator.platform) && /Safari/i.test(navigator.userAgent)){

window.addEventListener("resize", setViewportHeight, false);

window.addEventListener("scroll", setViewportHeight, false);

window.addEventListener("orientationchange", setViewportHeight, false);

setViewportHeight();

}

})();

相关文章:

  • 计算机专业i英语,计算机专业英语词汇
  • 计算机网络网线制作教案,制作网线教案.doc
  • 乡村少年宫计算机学科教案,乡村少年宫活动信息技术教案.doc
  • 计算机在建筑节能领域的作用,论文计算机模拟技术在建筑节能方面的应用.doc...
  • 重庆理工计算机考研分数线,2020重庆理工大学考研复试分数线已公布
  • 计算机操作员五级模似试题,计算机操作员模拟试题基础部分.doc
  • 关于计算机航天生物的想像作文,航天精神作文500字
  • 针对世界上第一台计算机的缺点,小学生信息学练习计算机基础.doc
  • 计算机大专当兵吃香吗,大专学生参军有这么多好处,现在已经有好多人后悔没参军...
  • curl怎么验证服务器证书,使用s_client但不是curl的客户端证书访问服务...
  • 服务器安装版u盘如何制作,U盘怎么安装原版Windows server 2016?
  • git自动部署代码到服务器windows,Jenkins-在windows上配置自动化部署(Jenkins+Gitlab+IIS)...
  • 手机无法服务器获取信息,荒野行动获取服务器信息一直不动怎么办 获取服务器信息为0解决方法...
  • ajax ashx返回datareader,C#ashx异步处理数据
  • 为什么服务器都是准系统,为了情怀,什么都值得_服务器准系统_服务器开发应用-中关村在线...
  • [译]如何构建服务器端web组件,为何要构建?
  • 【RocksDB】TransactionDB源码分析
  • C++类的相互关联
  • gf框架之分页模块(五) - 自定义分页
  • golang中接口赋值与方法集
  • HTML-表单
  • JavaScript设计模式系列一:工厂模式
  • JAVA之继承和多态
  • linux学习笔记
  • log4j2输出到kafka
  • Redis学习笔记 - pipline(流水线、管道)
  • Spring框架之我见(三)——IOC、AOP
  • Stream流与Lambda表达式(三) 静态工厂类Collectors
  • yii2权限控制rbac之rule详细讲解
  • 大型网站性能监测、分析与优化常见问题QA
  • 对象引论
  • 聊聊flink的TableFactory
  • 聊聊sentinel的DegradeSlot
  • 前端技术周刊 2019-02-11 Serverless
  • 详解NodeJs流之一
  • 一道闭包题引发的思考
  • 优秀架构师必须掌握的架构思维
  • 找一份好的前端工作,起点很重要
  • 终端用户监控:真实用户监控还是模拟监控?
  • [地铁译]使用SSD缓存应用数据——Moneta项目: 低成本优化的下一代EVCache ...
  • HanLP分词命名实体提取详解
  • ​Z时代时尚SUV新宠:起亚赛图斯值不值得年轻人买?
  • ​什么是bug?bug的源头在哪里?
  • # Java NIO(一)FileChannel
  • #{}和${}的区别?
  • #HarmonyOS:软件安装window和mac预览Hello World
  • #我与Java虚拟机的故事#连载18:JAVA成长之路
  • $.ajax()方法详解
  • ()、[]、{}、(())、[[]]命令替换
  • (003)SlickEdit Unity的补全
  • (173)FPGA约束:单周期时序分析或默认时序分析
  • (51单片机)第五章-A/D和D/A工作原理-A/D
  • (html5)在移动端input输入搜索项后 输入法下面为什么不想百度那样出现前往? 而我的出现的是换行...
  • (Matlab)使用竞争神经网络实现数据聚类
  • (Redis使用系列) Springboot 使用redis实现接口Api限流 十