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