Ionic nav-bar: Title is not centered on Android Device

后端 未结 9 1023
别跟我提以往
别跟我提以往 2021-02-01 17:20

Im very new to Ionic but i already like it. I wanted to use the nav-barso i implemented the following index.html:




        
相关标签:
9条回答
  • Hi i am changed css and redefine the css like this

    .bar.bar-header .button+.title {
    text-align: center !important;
    left: 35px;
    line-height: 46px;
    }
    

    its work for me.

    0 讨论(0)
  • 2021-02-01 17:58

    I think that this is a better solution for images. Add it to app.scss

    .back-button {
        z-index: 100;
    }
    ion-title {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      text-align: center;
    }
    
    0 讨论(0)
  • 2021-02-01 17:59

    I wrote a fix for Ionic 2.0.x

    Add the following style to your .scss file (I placed it in app.scss)

    //  Centering title
    // --------------------------------------------------
    // a fix for centering the title on all the platforms
    
    ion-header {
      .button-md {
        box-shadow: none;
      }
    
      .toolbar-title {
        display: -webkit-flex;
        display: flex;
        -webkit-flex-direction: row;
        flex-direction: row;
        -webkit-align-items: center;
        align-items: center;
        -webkit-justify-content: center;
        justify-content: center;
      }
    }
    

    After that add the following markup to your page

    <ion-header>
      <!-- use ion-toolbar for a normal toolbar and ion-navbar for navigation -->
      <ion-toolbar>
        <ion-buttons left>
          <!-- left aligned content here -->
        </ion-buttons>
    
        <ion-title>
          Your title or image
        </ion-title>
    
        <ion-buttons right>
          <!-- left aligned content here -->
        </ion-buttons>
      </ion-toolbar>
    </ion-header>
    
    0 讨论(0)
提交回复
热议问题