离子框架中的选项卡

tabs in ionic framework

本文关键字:选项 框架      更新时间:2023-09-26

我目前面临一些与离子标签和浮动标签概念相关的问题。

目前使用离子骨架..我正在构建一个移动应用程序,我希望在页面滚动到选项卡所在的位置后,选项卡固定在标题下方。我在离子内容物中保留了离子标签。

获得滚动位置后,我添加了一个"固定"类。 当它添加固定的类时,背景变为白色(不可见内容),选项卡被隐藏而不是固定在标题下方的位置。

$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>
我一直

在使用ionic.css文件,我找到了固定制表符的解决方案,但就像我说的,你将不得不编辑ionic.css文件。

您必须编辑以下内容:

.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 
}

有了这个,您将修复离子选项卡,但是如果您希望该条形标题也将固定,请编辑此

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