How to wordwrap a long string in ion-item

前端 未结 6 747
甜味超标
甜味超标 2020-12-13 08:04

IONIC has two problems about word-wrap in ion-item: 1. String would be truncated by the dots appended at the end, how to show full content without dots ? 2. Automatic line b

相关标签:
6条回答
  • 2020-12-13 08:37

    If you want a custom CSS class to have the same word wrapping effect, just add

    white-space: normal;
    

    to your class.

    Source: ionic forum

    0 讨论(0)
  • 2020-12-13 08:39

    In Ionic 2, use the text-wrap attribute

    <ion-item text-wrap>
      text here wraps to multiple lines
    </ion-item>
    
    0 讨论(0)
  • 2020-12-13 08:45

    For Ionic 4, use text-wrap on your ion-label element, like so:

    <ion-item>
        <ion-label text-wrap>
             Multiline text that should wrap when it is too long
             to fit on one line in the item.
        </ion-label>
      </ion-item>
    

    UPDATE: 10/30/2019 - CSS utility attributes are now deprecated in the latest version of Ionic 4, and will be going away completely in Ionic 5.

    It is recommended to use class="ion-text-wrap" moving forward:

    <ion-item>
        <ion-label class="ion-text-wrap">
             Multiline text that should wrap when it is too long
             to fit on one line in the item.
        </ion-label>
      </ion-item>
    
    0 讨论(0)
  • 2020-12-13 08:47

    For ionic 1:

    Add item-text-wrap class to item.

    <ion-item class="item-text-wrap">
      some long string
    </ion-item>
    

    For ionic 2:

    Add text-wrap attribute to item.

    <ion-item text-wrap>
      some long string
    </ion-item>
    
    0 讨论(0)
  • 2020-12-13 08:52

    Ionic 4

    class="ion-text-wrap"

      <ion-item>
        <ion-label class="ion-text-wrap">Long Text</ion-label>
      </ion-item>
    

    Link

    0 讨论(0)
  • 2020-12-13 08:52

    You can do it with CSS without adding ionic's volatile-garbage to your HTML like so

    I think that means style any ion-label inside an ion-item with the following style...

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