Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在iPad视口中保持jQuery模式_Jquery_Css_Ipad - Fatal编程技术网

在iPad视口中保持jQuery模式

在iPad视口中保持jQuery模式,jquery,css,ipad,Jquery,Css,Ipad,我已经写了一个相当直接的jQuery模型,因为我不想让任何东西变得沉重。除iPad外,modal在所有浏览器上都能正常工作 如果我在页面底部,单击打开灯箱,它将在页面顶部打开,看不见 我没有使用jQuery来定位窗口,只是纯css。有人能理解为什么除了iPad之外,其他浏览器都能使用jQuery吗 #lightbox { position:fixed; /* keeps the lightbox window in the current viewport */ top:0;

我已经写了一个相当直接的jQuery模型,因为我不想让任何东西变得沉重。除iPad外,modal在所有浏览器上都能正常工作

如果我在页面底部,单击打开灯箱,它将在页面顶部打开,看不见

我没有使用jQuery来定位窗口,只是纯css。有人能理解为什么除了iPad之外,其他浏览器都能使用jQuery吗

#lightbox { position:fixed; /* keeps the lightbox window in the current viewport */ top:0; left:0; width:100%; height:100%; z-index: 2; background-color: rgba(0, 0, 0, 0.2); font-weight: 100; margin: 0 0 .1em 0; color: #f8ef71; text-shadow: 1px 1px 1px #af7913; text-align: center; } #灯箱{ 位置:固定;/*将灯箱窗口保持在当前视口中*/ 排名:0; 左:0; 宽度:100%; 身高:100%; z指数:2; 背景色:rgba(0,0,0,0.2); 字号:100; 边际:0.1米0; 颜色:#f8ef71; 文本阴影:1px 1px 1px#af7913; 文本对齐:居中; }
位置:fixed不是普遍支持的,我想您的iOS版本低于版本5,这是第一个支持它的iOS版本?此模式也不会出现在IE6和IE7上。如果不禁用viewport meta标记的缩放功能,它在Android 2.3及更低版本中也不会工作

使用“位置”时会遇到的另一个困难:已修复的是,它是相对于窗口而不是视口的,因此在缩放元素时,它不会以您想要的方式显示。这就是为什么他们在安卓2.3中禁用了fixed,但没有禁用zoom(或者我相信是这样),尽管他们在以后的安卓版本中改变了这个位置

这里有一个相关的问题:
感谢Ed Kirk提醒我iOS 5之前版本中的位置修复问题

我写了一个小JS来解决我的问题

if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod') { var cssObj = { 'background-color' : 'rgba(0, 0, 0, 0)', 'position' : 'absolute', 'top' : $(document).scrollTop() }; $('#lightbox').css(cssObj); $(window).scroll(function() {$('#lightbox').animate({top: $(document).scrollTop()}, 300);}); }; 如果(navigator.platform==“iPad”| | navigator.platform==“iPhone”| | navigator.platform==“iPod”) { var cssObj={ “背景色”:“rgba(0,0,0,0)”, '位置':'绝对', 'top':$(文档).scrollTop() }; $('#lightbox').css(cssObj); $(window.scroll(function(){$('#lightbox')).animate({top:$(document.scrollTop()},300);}); };