html - 文本(标签)没有占用 ionic 列表中的所有可用空间

标签 html css ionic-framework android-listview ionic4

我是 Ionic 和移动开发的新手。我正在使用 ionic 列表,如何使文本全屏可用(请参阅图片中的最后收到)并且可以使用 <ion-label> 吗?周围<h4><p>

<ion-list>
<ion-item *ngFor ="let connection of connections">
  <ion-avatar slot="start">
    <img [src]="connection?.picture">
  </ion-avatar>
<ion-label text-wrap>
  <h4>{{ connection?.name}}</h4>
  <p text-wrap> Last received:  {{ connection?.locationDesc }}</p>
</ion-label>

<ion-label slot="end" text-right>
  <p item-end> 2 Messages </p>
  <ion-button clear slot="end">View</ion-button>
</ion-label>          
</ion-item>

enter image description here

最佳答案

看起来它只需要一点点,但它实际上做的是与您放入的两个标签共享 50 50 以用作列。由于自动换行,它看起来只用了不到一半。

这是因为标签根据这些规则被设置为 flex 元素。

我设法做到了这一点:

enter image description here

通过使用此代码:

  <ion-list>
    <ion-item>
      <ion-avatar slot="start">
        <img src="/assets/matthew.jpg">
      </ion-avatar>
      <ion-label  class="ion-text-wrap">
        <h4>Some name</h4>
        <p> Last received: All plugins have two components - the native code (Cordova) and the
          JavaScript code. Cordova plugins are also wrapped in a Promise or Observable in order to provide a common
          plugin interface. Below are various framework options using the Camera plugin as an example. </p>
      </ion-label>
      <ion-note class="ion-text-end">
        <p> 2 Messages </p>
        <ion-button clear>View</ion-button>
      </ion-note>
    </ion-item>
  </ion-list>

基本上我将最后一个 ion-label 换成了 ion-note

我还搞砸了其他事情,比如删除不需要的插槽并将属性转换为 appropriate utility classes这现在被认为是最佳实践(因为他们引入了不支持这些属性的 React 和 Vue)。

关于html - 文本(标签)没有占用 ionic 列表中的所有可用空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58775790/

相关文章:

html - 如何在 .scss 文件中包含外部 CSS 文件作为类的规则?

css - IE 错误 - 内容向左浮动

css - 绑定(bind)不适用于属性 "class"

ios - Ionic SVG 图像在 iOS 上运行缓慢

ios - 在 Cordova/Ionic/iOS 中滚动时的空白区域

html - 调整浏览器大小时如何停止水平重叠?

html - 如何仅使用 css/html 使文本滑动

android - Ionic android/ios www转apk流程

php - 如何获取没有html标签的文本

html - 如何让文本显示在 <IMG> 标签下方