简体   繁体   English

IOS7中的画布外弹出菜单浓缩到页面中,而不移出画布

[英]Off-canvas flyout menu in IOS7 condensing into page, not moving off canvas

Just as the title suggests, I am making a website that utilizes the "off canvas" menu approach to save space and modernize the look and feel of the site on mobile devices. 就像标题所暗示的那样,我正在制作一个网站,该网站使用“非画布”菜单方法来节省空间并在移动设备上现代化该网站的外观。

The exact problem is that the menu itself will not move off the canvas when the page is loaded in iOS 7 on an iPad. 确切的问题是,当页面在iPad上的iOS 7中加载时,菜单本身不会移出画布。 This is not the case in iOS 6 though, when I checked it. 当我检查时,iOS 6中不是这种情况。 The flyout works perfectly on my desktop when I resize the browser window. 当我调整浏览器窗口的大小时,弹出按钮可以在桌面上完美运行。

This is what it looks like on an iPad Air with iOS 7 这就是在装有iOS 7的iPad Air上的外观

在此处输入图片说明

I was surprised to find that the layout actually worked as expected in iOS 6 with an earlier iPad. 令我惊讶的是, 该布局实际上在使用早期iPad的iOS 6中能够按预期工作 I am racking my brains trying to figure this out. 我竭尽全力试图解决这个问题。 Here is the code I am working with (note: I am using the Bootstrap 3 framework underneath all of this): 这是我正在使用的代码(注意:我在所有这些下面使用Bootstrap 3框架):

HTML HEADER HTML标题

<meta name="viewport" content="width=device-width, initial-scale=1.0">

GLOBAL DEVICE-RELATED CSS 全球设备相关CSS

@-webkit-viewport   { width: device-width; }
@-moz-viewport      { width: device-width; }
@-ms-viewport       { width: device-width; }
@-o-viewport        { width: device-width; }
@viewport           { width: device-width; }

MENU CSS 菜单CSS

@media screen and (max-width: $screen-tablet) {
    #nav {
      position: absolute;
      top: 0;
      padding-top: 5.25em;
    }
    #nav .block {
      position: relative;
      padding: 0;
    }

    .js-ready #nav {
      height: 100%;
      width: 70%;
      background: #333333;
    }
    .js-ready #nav .block {
      background: transparent;
    }   
    .js-ready #nav {
      left: -70%;
    }
    .js-ready #inner-wrap {
      left: 0;
    }
    .js-nav #inner-wrap {
      left: 70%;
    }
  }
}

JAVASCRIPT JAVASCRIPT

// Toggle the mobile navigation off-canvas menu
$(document).on('click', '.nav-btn', function(event)
{   
    event.preventDefault();

    if ($('html').hasClass('js-nav-in'))
{
    $('html').removeClass('js-nav-in').addClass('js-nav-out');
}
    else if ($('html').hasClass('js-nav-out'))
{
    $('html').removeClass('js-nav-out').addClass('js-nav-in');
}
});

I'm sorry for the code dump, but that seems to make this a more complex issue. 对于代码转储,我感到抱歉,但这似乎使这成为一个更加复杂的问题。 Any tips or suggestions anyone has would be appreciated. 任何人的任何提示或建议,将不胜感激。 I am willing to completely rebuild the menu if it means that this menu would work across the bulk of tablets and mobile phones. 如果这意味着该菜单可在大多数平板电脑和手机上使用,我愿意完全重建该菜单。

As a note, when I tap on the menu icon or closing x the view zooms in as if the total width of the page is less. 请注意,当我点击菜单图标或关闭x时,视图将放大,好像页面的总宽度较小。 I think this may be a complete rebuild type situation. 我认为这可能是一个完整的重建类型的情况。 If you know of a resource where I would be able to see how this could be properly done, I would accept it. 如果您知道可以在哪里正确完成此工作的资源,我将接受。

EDIT: The sizing seems to work in iOS 7 Safari. 编辑:调整大小似乎可以在iOS 7 Safari中使用。 However, when the user swipes to the side, the menu comes out. 但是,当用户滑动到侧面时,菜单就会出现。 This is still an issue, just a different one. 这仍然是一个问题,只是一个不同的问题。 Any helpful resources would be appreciated. 任何有用的资源将不胜感激。

As a test, could you change your CSS to hide the navigation ( #nav {display:none;} )on top of positioning it off the page. 作为测试,是否可以更改CSS以隐藏导航( #nav {display:none;} ),以将其定位在页面之外。 Then have your jquery .show(); 然后用你的jquery .show(); and .hide(); .hide(); the nav respectively when the user clicks on the menu along with your slide in/out transition. 用户在菜单上单击以及导航滑入/滑出过渡时分别进行导航。

My gut instinct is that since the nav is technically still part of the layout (it's just off to the right, presumably with overflow:hidden on the parent container), but iOS is thinking its part of the layout and is including it somehow. 我的直觉是,由于导航技术在技术上仍是布局的一部分(它在右边,大概是在父容器中overflow:hiddenoverflow:hidden ,但iOS仍在考虑布局的一部分并以某种方式包括它。

So as a test, hide the nav and I'm thinking iPad iOS7 should respect it being gone and have your "page" take up the full width of the viewport (that's my theory at least). 因此,作为一项测试,隐藏导航,我认为iPad iOS7应该尊重它的消失,并使您的“页面”占据视口的整个宽度(至少这是我的理论)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM