jQuery移动定位变更解决方案

时间:2013-08-10 01:15:35

标签: css jquery-mobile orientation landscape portrait

我正在开发一个jQuery Mobile应用程序。它有大量动态生成的CSS,到目前为止,我一直在为纵向方向开发所有内容。显而易见的问题是,当我倾斜设备时,它看起来非常糟糕。我不需要为应用程序提供横向视图,但我也不反对它。任何人都可以建议一个最简单的解决方案,选择是横向视图还是以某种方式在纵向模式下锁定应用程序?

1 个答案:

答案 0 :(得分:0)

检查方向有两种方法.. 首先 1)

$(window).bind("orientationchange", function(evt){
                   alert(evt.orientation);
/*do what you want.*/
                   });

其次使用css你可以使用min-width检查。我正在使用iPad然后我检查768和1024.做的事情

@media screen and (min-width: 768px){
    #realTimeContents {
   overflow-y:auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  height:850px 

}
}
@media screen and (min-width: 1024px){
    #realTimeContents {
   overflow-y:auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  height:600px 

}
}