Ionic item with left and right aligned text

前端 未结 8 2444
半阙折子戏
半阙折子戏 2021-02-19 23:38

I have an ionic item in an ionic list. What is the best way to left align the first text and right align the second text?

  
相关标签:
8条回答
  • 2021-02-19 23:58

    In ionic 2 just use

    text-left,text-right

    <div class="item">
        <span text-left>first</span>
        <span text-right>second</span>
    </div>
    

    Read More :- https://github.com/driftyco/ionic/typography.scss

    0 讨论(0)
  • 2021-02-19 23:58

    I use Ionic 3 and the best anwser I think is to use the ionic tags and attributes:

    <ion-list>
      <ion-item>
        <ion-label>
          this to the left
        </ion-label>
        <ion-label text-right>
          this to the right
        </ion-label>
      </ion-item>
    </ion-list>
    
    0 讨论(0)
  • 2021-02-20 00:02

    With Ionic 2 & above, you can use Element Placement Attributes like float-left or float-right on your HTML elements instead of adding properties like float: left; or float: right; on your scss

    https://ionicframework.com/docs/theming/css-utilities/#float-elements

    <div class="item">
      <span float-left>first</span>
      <span float-right>second</span>
    </div>
    
    0 讨论(0)
  • 2021-02-20 00:05

    This can be done using basic CSS properties. there is nothing specic about ionic here. This can be done using float:left and float:right properties.

    Still for your reference, you can go through this link.

    0 讨论(0)
  • 2021-02-20 00:06

    You also use ionic's class and attribute to do that. For exemple

    <div class="item row">
       <span align="right" class="col col-50">first</span>
       <span align="left" class="col col-50">second</span>
    </div>
    
    0 讨论(0)
  • 2021-02-20 00:09

    Ionic uses CSS Utilities. They provide their own way of aligning text.

    <div class="item">
      <span>first</span>
      <span>second</span>
    </div>

    More about CSS utilities at https://ionicframework.com/docs/theming/css-utilities/#text-alignment

    0 讨论(0)
提交回复
热议问题