JavaScript-离子含量与ion-header-b重叠

我正在建立基于离子框架的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>
BAE asked 2020-06-30T05:08:44Z
6个解决方案
86 votes

参见:[http://jsbin.com/pagacohovohe/1/edit]

将class =“ has-header”赋予离子含量。

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

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

user1788175 answered 2020-06-30T05:09:07Z
13 votes

这里出现了与离子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>
corolla answered 2020-06-30T05:09:28Z
6 votes

您可以尝试像这样设置“具有副标题”类

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

参见:[http://ionicframework.com/docs/components/#subheader]

user875367 answered 2020-06-30T05:09:52Z
6 votes
<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>
Shally12 answered 2020-06-30T05:10:08Z
0 votes

在我的情况下,第一个选项具有* ngIf值,该值包含基于用户角色的数据,该数据是在用户登录后获得的。登录后,我最终没有显示此项目。 首次登录后,当数据存储在存储器中时,将显示该项目。

Bujar Deari answered 2020-06-30T05:10:28Z
0 votes

具有标题,并且任何CSS类和属性均不适用于离子。您可以尝试填充顶部

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

Aman Gupta answered 2020-06-30T05:10:48Z
translate from https://stackoverflow.com:/questions/25408257/ion-content-overlap-with-ion-header-bar