【问题标题】:Jquery Mobile - Grid BreakpointJquery Mobile - 网格断点
【发布时间】:2013-10-13 19:17:00
【问题描述】:

我正在使用以下 jqm 网格,我希望每个网格在方向更改为纵向模式时堆叠在一起,我认为目前的断点是 45em。

我使用了下面的语法,但是没有用,有什么建议吗?

//为 1200 像素宽度添加最小/最大类
$.mobile.addResolutionBreakpoints(1200);

//为 1200 和 1440 像素宽度添加最小/最大类
$.mobile.addResolutionBreakpoints([1200, 1440]);

网格:

网格 B (33/33/33)

A座 B座 C座

【问题讨论】:

标签: jquery html jquery-mobile mobile responsive-design


【解决方案1】:

你可以通过监听orientationchange事件来实现。

首先,创建一个将添加到块中的自定义类。

.blocks {
  width: 100% !important;
}

pageshowpagebeforeshow 上,如果屏幕高度大于宽度(纵向),则添加该类。

$(document).on('pagebeforeshow', function () {
  if ($(this).height() > $(this).width()) {
    $('.ui-block-a, .ui-block-b, .ui-block-c').addClass('blocks');
  }
});

orientationchange 添加/删除该类。

$(window).on('orientationchange', function (e) {
  if (e.orientation == 'landscape') {
    $('.ui-block-a, .ui-block-b, .ui-block-c').removeClass('blocks');
  }
  if (e.orientation == 'portrait') {
    $('.ui-block-a, .ui-block-b, .ui-block-c').addClass('blocks');
  }
});

Demo

【讨论】:

    猜你喜欢
    • 2011-08-16
    • 2011-12-08
    • 1970-01-01
    • 1970-01-01
    • 2013-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多