【问题标题】:CSS/JS select devices that are not landscape and min-width of 980pxCSS/JS 选择非横向且最小宽度为 980 像素的设备
【发布时间】:2014-08-27 15:33:43
【问题描述】:

我有一个小问题正在尝试解决。在我的 drupal 网站上,我编写了一个脚本,它允许 shadowboxes 打开 youtube 链接,其最小宽度为 980 像素。这很好用,但我的问题来自面向横向的平板电脑。这条规则是为了防止 shadowbox 在移动平台上打开。所以我想修改我的代码以防止任何横向设备以及980px以下的所有设备。我可以就这背后的逻辑获得一些帮助吗?我尝试使用 NOT (orientation:landscape),但我相信 NOT 反转了整行的逻辑。

(function ($, Drupal, window, document, undefined) {

  $(document).ready(function () {
    var mq = window.matchMedia( "(min-width: 980px)" );
    if (mq.matches) {
      Shadowbox.init();
    }
  });

})(jQuery, Drupal, this, this.document);

【问题讨论】:

    标签: javascript jquery drupal media tablet


    【解决方案1】:

    所以,我在发布后立即意识到我做错了什么。我会留下它,以防它帮助其他人。我忘记了它需要一个逗号来分隔查询。

    (function ($, Drupal, window, document, undefined) {
    
      $(document).ready(function () {
        var mq = window.matchMedia( "(not (orientation:landscape),(min-width: 980px)" );
        if (mq.matches) {
          Shadowbox.init();
        }
      });
    
    })(jQuery, Drupal, this, this.document);
    

    【讨论】:

      猜你喜欢
      • 2013-03-30
      • 2020-10-12
      • 2011-02-05
      • 1970-01-01
      • 2013-08-27
      • 2012-05-19
      • 2014-11-02
      • 2014-10-22
      • 2013-11-25
      相关资源
      最近更新 更多