溢出-x隐藏导致响应导航菜单定位问题

时间:2016-08-31 20:25:52

标签: html css twitter-bootstrap

问题背景:

我正在使用Jasny Bootstrap来实现响应式的offcanvas'揭示'风格菜单。

问题:

在移动设备上打开菜单时,菜单的滚动元素无法启用。

我已将整个应用程序(我的AngularJS视图已注入)包装为div样式overflow-y:hidden,如下所示:

<body ng-app="app">
    <div style="overflow-x:hidden">
        <div ui-view style="height:100%">
            //View is injected here based on routing.
        </div>
    </div>
</body>

这种溢出样式意味着我现在可以在移动设备上滚动菜单但我现在有一个问题在哪里和当菜单滚动到顶部时,显示下面的菜单有一个间隙,如下所示:

enter image description here

页面向下滚动后,响应式导航栏会显示:

enter image description here

守则:

以下是如上所示,这是主视图div,根据其路由注入页面:

<body ng-app="app">
    <div style="overflow-x:hidden">
        <div ui-view style="height:100%">
            //View is injected here based on routing.
        </div>
    </div>
</body>

这是包含导航栏元素的应用的结果视图:

<div ng-controller="ResultsController" ng-show="hideSearch" style="height:100%">
    <div class="navmenu navmenu-default navmenu-fixed-left" id="updateMenu">
        <div class="text-center headerPad"><h3>Compzee <img src="Images/CompzeeLogoSmall.png" class="logoSize" /></h3></div>
        <div class="col-lg-12 pullInMenu">
            <form ng-submit="search()" novalidate="novalidate">
                <div class="form-group">
                    <label for="search">Search Term:</label>
                    <input type="text" class="form-control" ng-model="item" id="itemUpdate" required>
                </div>
                <div class="form-group">
                    <label for="search">Product Category:</label>
                    <select class="form-control" ng-model="catagory" required>
                        <option value="" disabled selected>Select A Product Category</option>
                        <option>All</option>
                        <option>Baby</option>
                        <option>Business, Office &amp; Industrial</option>
                        <option>Cameras &amp; Photography</option>
                        <option>Clothes &amp; Accessories</option>
                        <option>Comics, Books &amp; Magazines</option>
                        <option>Computers &amp; Tablets</option>
                        <option>Consoles</option>
                        <option>DVD's, Films &amp; TV</option>
                        <option>Garden &amp; Patio</option>
                        <option>Health &amp; Beauty</option>
                        <option>Holiday &amp; Travel</option>
                        <option>Home</option>
                        <option>Kitchen</option>
                        <option>Jewellery</option>
                        <option>Mobile Phones &amp; Accessories</option>
                        <option>Musical Instruments</option>
                        <option>Music</option>
                        <option>Pet Supplies</option>
                        <option>Shoes</option>
                        <option>Sporting Goods</option>
                        <option>Toys &amp; Games</option>
                        <option>Vehicle Parts &amp; Accessories</option>
                        <option>Video Games</option>
                        <option>Watches</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="search">Country:</label>
                    <select class="form-control" ng-model="selectedCountry" required>
                        <option value="" disabled selected>Select A Country</option>
                        <option>UK</option>
                        <option>US</option>
                        <option>FR</option>
                        <option>DE</option>
                    </select>
                </div>
                <div class="form-group">
                    <div class="text-center">
                        <img ng-src="{{countryImg}}" />
                    </div>
                </div>
                <div class="form-group">
                    <label for="search">Marketplace</label>
                    <select class="form-control" ng-model="selectedMarketPlace" required>
                        <option value="" disabled selected>Select A Marketplace</option>
                        <option>Ebay & Amazon</option>
                        <option>Ebay</option>
                        <option>Amazon</option>
                    </select>
                </div>
                <div class="form-group">
                    <div class="text-center">
                        <img class="marketPlaces" ng-src="{{image}}" />
                        <img class="marketPlaces" ng-show=" showImg" ng-src="{{imageSecond}}" />
                    </div>
                </div>
                <div class="form-group">
                    <div class="content">
                        <rzslider rz-slider-model="minRangeSlider.minValue" rz-slider-high="minRangeSlider.maxValue" rz-slider-options="minRangeSlider.options"></rzslider>
                    </div>
                </div>
                <div class="form-group">
                    <label for="search">Min Price</label>
                    <input type="text" class="form-control" ng-model="minTextVal" id="slider-margin-value-min" readonly>
                </div>
                <div class="form-group">
                    <label for="search">Max Price</label>
                    <input type="text" class="form-control" ng-model="maxTextVal" id="slider-margin-value-max" readonly>
                </div>
                <div class="form-group text-center">
                    <label for="search">Prices High To low</label>
                    <input id="highToLowBox" type="radio" ng-value="true" ng-model="priceOrder">
                </div>
                <div class="form-group text-center">
                    <label for="search">Prices Low To high</label>
                    <input id="lowToHighBox" type="radio" ng-value="false" ng-model="priceOrder">
                </div>

                <div class="form-group">
                    <button class="btn btn-success" ladda="searchingService.updating" type="submit" data-style="zoom-in" style="width:100%">
                        <span>Update</span>
                    </button>
                </div>
            </form>
        </div>
    </div>
    <div class="canvas" id="resultsView">
        <div class="navbar navbar-default navbar-fixed-top">
            <button id="menuBtn" type="button" ng-click="ScrollUp()" class="navbar-toggle" data-toggle="offcanvas" data-recalc="false" data-target=".navmenu" data-canvas=".canvas">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
        </div>
        <div id="containerId" class="container">
            <div class="topOffSet ">
                <div class="col-lg-12 text-center">
                    <div id="itemHolder">
                        <h4><b>{{searchingService.searchList.length}} Results found from your search criteria.</b></h4>
                        <div class="panel panel-default col-lg-12 text-center" ng-show="searchingService.noResults">
                            <div class="panel-body"><img src="Images/CompzeeLogoSmall.png" class="logoSize" /><p>We could not find any results to match your search criteria</p><p>Please review your search terms and try again.</p></div>
                        </div>
                        <div ng-repeat="item in searchingService.filteredItems" class="col-lg-4">
                            <div class="panel panel-default maxPanelHeight">
                                <div class="panel-heading textOverflow" id="panelHeading">
                                    <h3 class="panel-title text-center"><b>{{item.Title}}</b></h3>
                                </div>
                                <div class="panel-body">
                                    <a href={{item.url}} target="_blank"><img src={{item.Image}} class="picHeight img-rounded img-responsive center-block" /></a>
                                    <h4 class="text-center"><b>{{item.Price}}</b></h4>
                                    <h4 class="text-center"><a href={{item.url}} class="btn btn-success" target="_blank">See More</a></h4>
                                    <div class="text-center"><img class="originPic" src={{item.marketPlaceImg}} /></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-lg-12 text-center">
                <uib-pagination total-items="items.length" ng-model="currentPage" max-size="maxSize" class="pagination-md" boundary-links="true" rotate="false">
                </uib-pagination>
            </div>
        </div>
    </div>
</div>

2 个答案:

答案 0 :(得分:1)

如果您有z-index问题:

  1. 添加z-index:1000;到.navmenu班。
  2. 如果仍然没有在顶部显示,请添加z-index:1;到.canvas类。
  3. 如果仍然不起作用,则表示您在其他类(.canvas或.navmenu类的子标记或父标记)中使用z-index。要解决它,你需要删除它们。为了搜索它,你只需在整个项目中搜索z-index,找出导致问题的那个,然后再次尝试编号1和2。请注意内联样式。不要只搜索你的css文件。 (我不知道您的IDE是什么,但如果您使用的是Eclipse,只需按CTRL + H并输入z-index来搜索整个项目)
  4. 如果您执行了1,2和3但仍然无效,则表示您已缓存并需要清除缓存。
  5. 如果您有高度问题:

    放高:100%;你在哪里写了overflow-x:hidden。高度100%表示父母身高的100%。当你将父高度为200px的节点放入高度:100%时。它意味着节点高度将是200px而不是更多。

答案 1 :(得分:0)

使用z-index属性显示另一个元素。

更大的z指数将会上升。

例子:z-index:2将显示为z-index:1。