【问题标题】:ion-content overlap with ion-header-barion-content 与 ion-header-bar 重叠
【发布时间】:2014-10-14 00:28:39
【问题描述】:

我正在构建基于 ionic 框架的 phonegap 应用程序。在一个html页面中,我需要一个标题和一个内容。但是标题与内容重叠。很抱歉,我没有足够的声誉来发布图片。

代码如下。 html页面与lib文件夹在同一个文件夹,其中包含ionic css和js文件夹。

    <html>
    <head>
    <meta charset="utf-8">
    <title>Weather</title>

    <!-- Sets initial viewport load and disables zooming  -->
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="stylesheet" href="lib/css/ionic.css">

    <script src="lib/js/ionic.bundle.js"></script>
    <script src="lib/js/angular/angular-resource.js"></script>
    </head>
    <body>
        <ion-header-bar class="bar bar-header bar-dark">
          <h1 class="title">Settings</h1>
          <button class="button button-clear" ng-click="closeSettings()">Close</button>
        </ion-header-bar>
        <ion-content has-header="true">
          <div class="padding">
            <div class="list">
              <label class="item item-input">
                <span class="input-label">Units</span>

                <ion-radio-buttons ng-model="settings.tempUnits">
                  <button class="button button-positive button-radio" ng-value="'f'">&deg;F</button>
                  <button class="button button-positive button-radio" ng-value="'c'">&deg;C</button>
                </ion-radio-buttons>
              </label>
            </div>
          </div>
        </ion-content>

    <!-- <ion-pane id="wrapper"> -->
<!--        <ion-header-bar class="bar bar-header bar-dark">
            <button class="button icon-left ion-chevron-left button-clear button-dark" onclick="goBack()">Back</button>
            <div class="title">xxx</div>
            <button class="button button-icon icon ion-navicon"></button>
        </ion-header-bar>
    </body>
</html>

【问题讨论】:

    标签: javascript html css cordova ionic-framework


    【解决方案1】:

    has-header 和任何 css 类和属性在 ionic 中不起作用。 你可以试试 padding-top

    <ion-content padding-top>
    <ion-grid padding-top>
      <ion-row padding-top>
        <ion-col padding-top>
    
            <ion-card class="foodCard">
              <img src="#">
    
                <ion-card-header>
                  <ion-card-title>Card Title</ion-card-title>
                </ion-card-header>
    
                <ion-card-content>
                  Keep close to Nature's heart... and break clear away, once in awhile,
                  and climb a mountain.
                </ion-card-content>
    
              </ion-card> 
    
        </ion-col>
      </ion-row>
    </ion-grid>
    

    【讨论】:

      【解决方案2】:

      来到这里与 Ionic 2 有同样的问题:导航栏重叠内容。就我而言,这是因为我在离子含量上有一个 *ngIf。解决方案是将 *ngIf 移动到内部元素中,例如 ng-container(感谢@TwitchBronBron):

      <ion-header>
        <ion-navbar>
          <ion-title>
            ...
          </ion-title>
        </ion-navbar>
      </ion-header>
      <ion-content padding>
        <ng-container *ngIf="...">...</ng-container>
      </ion-content>
      

      【讨论】:

      • 谢谢,这是我的问题!知道这是否会导致页脚导航栏做同样的事情吗?
      • 如果不想添加新元素,也可以使用&lt;ng-container *ngIf="..."&gt;...&lt;/ng-container&gt;
      【解决方案3】:

      在我的情况下,第一个有一个 *ngIf ,其中包含基于用户登录后我获得的用户角色的数据。我最终得到这个项目在登录后没有显示。首次登录后,数据存储在存储中,然后项目显示。

      【讨论】:

        【解决方案4】:
        <ion-view view-title="BBS">
            <ion-header-bar class="bar bar-subheader">
                <div class="button-bar">
                    <a class="button">web game</a>
                    <a class="button">mobile game</a>
                </div>
            </ion-header-bar>
            <ion-content class="has-header">
        
            </ion-content>
        </ion-view>
        

        【讨论】:

          【解决方案5】:

          你可以尝试像这样设置'has-subheader'类

              <ion-content class='has-header has-subheader'>
              ...
              </ion-content>
          

          见:http://ionicframework.com/docs/components/#subheader

          【讨论】:

            【解决方案6】:

            见:http://jsbin.com/pagacohovohe/1/edit

            将 class="has-header" 赋予 ion-content。

            <ion-content class="has-header">
            </ion-content>
            

            您需要初始化您的 Angular 应用程序 - 请参阅我的示例中的 javascript。注意 ng-controller 和 ng-app。

            【讨论】:

            • 谢谢。但它们仍然重叠。
            • @ChengchengPei 试试我的新答案。
            • 谢谢。但它们仍然重叠。
            • @ChengchengPei 检查我发布的链接。
            • 谢谢。现在可以了。我使用你给我的 javascript 来初始化 html 页面,现在它可以工作了。感谢您的帮助。
            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 2019-11-07
            • 2017-01-11
            • 2018-08-09
            • 1970-01-01
            • 1970-01-01
            • 2021-01-08
            • 1970-01-01
            相关资源
            最近更新 更多