简体   繁体   English

离子框架中的选项卡

[英]tabs in ionic framework

I am currently facing some issues related to ionic-tabs and Floating tabs concept. 我目前面临一些与离子标签和浮动标签概念有关的问题。

Currently using ionic framework..I am building a mobile app in which I want tabs to get fixed below header once the page is scrolled till the position where the tab is. 当前正在使用ionic框架。.我正在构建一个移动应用程序,在该应用程序中,我希望一旦页面滚动到选项卡所在的位置,选项就可以固定在标题下方。 I have kept ion-tabs inside ion-content. 我把离子标签放在离子含量里面。

After getting the scroll position I have added a class "fixed". 获得滚动位置后,我添加了一个“固定”类。 As it adds the class fixed,the background changes to white (no content visible) and the tabs get hidden instead of getting fixed at the position below header. 当它添加固定的类时,背景变为白色(看不到任何内容),并且选项卡被隐藏而不是固定在标题下方的位置。

$scope.onScroll = function() {

    var scrollWidth = $(".bar".height() + $(".maincontent".height(); console.log($ionicScrollDelegate.getScrollPosition()); console.log(scrollWidth);
          if (parseInt($ionicScrollDelegate.getScrollPosition().top) > scrollWidth) {

            $('ion-tabs').addClass('fixed');
          } else {
            $('ion-tabs').removeClass('fixed');
          }
        };
.fixed {
  left: 0;
  top: 44px;
  position: fixed;
  z-index: 100;
  width: 100%;
}
<ion-view>
  <ion-header-bar class="bar bar-positive">
  </ion-header-bar>

  <ion-content on-scroll="onScroll()">
    <div class="main-content">

      <!-- some content here -->

    </div>
    <ion-tabs class="tabs-icon-top tabs-color-active-dark tabs-background-positive tabs-striped tabs-top">
      <!-- About Tab -->
      <ion-tab title="About">
        <ion-nav-view>
          <div>
            <!--some tab content -->
          </div>
        </ion-nav-view>
      </ion-tab>

      <!--update Tab -->
      <ion-tab title="Updates">
        <ion-nav-view animation="slide-left-right">
          <ion-view>
            <ion-content scroll="false">

              <!-- some other tab content -->

            </ion-content>
          </ion-view>
        </ion-nav-view>
      </ion-tab>
    </ion-tabs>
  </ion-content>
</ion-view>

I have been playing with the ionic.css file and I found a solution for fixed tabs, but like I say you will have to edit the ionic.css file. 我一直在使用ionic.css文件,并且找到了固定选项卡的解决方案,但是就像我说的那样,您必须编辑ionic.css文件。

You must edit this: 您必须编辑以下内容:

.tabs-top.tabs-striped
{
   padding-bottom: 0;
   position: fixed;
   z-index: 9999
}
.tabs-top > .tabs, .tabs.tabs-top 
{
  top: 44px;
  padding-top: 0;
  background-position: bottom;
  border-top-width: 0;
  border-bottom-width: 1px;
  position: fixed;
  z-index: 9999 
}

With this you will have the ion-tabs fixed, but if you want that bar-header will also be fixed, then edit this 有了它,您将固定离子标签,但是如果您希望也固定条形标题,请编辑此标签

.bar-header 
{
  top: 0;
  border-top-width: 0;
  border-bottom-width: 1px;
  position: fixed;
  z-index: 9999 
}

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

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