jQuery innerWidth减去高度不工作' if else'在较小的设备上

时间:2017-11-01 14:51:25

标签: jquery html css responsive-design

我可以编写一些代码,允许我在大型和低分辨率设备上设置窗口高度,这允许我使用Flexbox将内容置于设备中间。

我使用if (window.innerWidth >= 1023) {} else {来检测较小的屏幕,这可以在大型和小型设备的主页上发挥作用。然而,.flexAligner似乎正在设置“高度”。但忽略- 88,这只会在不是主页的网页上发展,即没有.home .intro

我无法理解为什么它的工作不正确,希望有人可以指出为什么- 88无效。我认为这与拉斯维加斯滑块提升元素这一事实有关,而后者则不然。

短片不起作用:

} else {
    windowHeight = $(window).innerHeight();
    $('.nanoContainer, .flexAligner, .home .intro').css('min-height', windowHeight - 88);

完整代码:

$(function() {
  $(window).resize(function() {
    if (window.innerWidth >= 1023) {
      windowHeight = $(window).innerHeight();
      $('.nanoContainer, .flexAligner, .vegas-container, .justHeight').css('min-height', windowHeight);
      $("body.home").vegas({
        delay: 8000,
        transition: 'fade',
        transitionDuration: 8e3,
        timer: false,
        slides: [
          { src: "/wp-content/uploads/slide-01-desktop.jpg" },
          { src: "/wp-content/uploads/slide-02-desktop.jpg" },
          { src: "/wp-content/uploads/slide-03-desktop.jpg" }
        ],
        animation: "kenburns"
      });
      $(".home .intro").vegas('destroy');
    } else {
      windowHeight = $(window).innerHeight();
      $('.nanoContainer, .flexAligner, .home .intro').css('min-height', windowHeight - 88);
      $(".home .intro").vegas({
        delay: 8000,
        transition: 'fade',
        transitionDuration: 8e3,
        timer: false,
        cover: false,
        slides: [
          { src: "/wp-content/uploads/slide-01-mobile.jpg" },
          { src: "/wp-content/uploads/slide-02-mobile.jpg" },
          { src: "/wp-content/uploads/slide-03-mobile.jpg" }
        ],
        animation: "fade"
      });
      $("body.home").vegas('destroy');
    }
  }).resize();
});

1 个答案:

答案 0 :(得分:2)

尝试:

set validExtensions to {"xml"}
tell application "Finder"
    set theXMLFolder to choose folder with prompt "Select the folder containing the xml files:"
    repeat with i from 1 to (count of files in folder theXMLFolder)
        set theXMLFile to item i of theXMLFolder
        if name extension of theXMLFile is in validExtensions then
            --  # Do something.
            log (get name of item i of folder theXMLFolder)
        end if
    end repeat
end tell

我添加了括号,用windowHeight

对88进行分组