html - 最小化 ion-text 上显示的文本行
问题描述
HTML:
<ion-list *ngFor="let message of messages">
<ion-item lines="none" type="button" button="true">
<ion-grid>
<ion-row>
<ion-col class="message">
<ion-text>
{{ message.text }}
</ion-text>
</ion-col>
</ion-row>
</ion-grid>
</ion-item>
</ion-list>
CSS:
.message {
color: var(--ion-color-default-shade) !important;
border-radius: 5px;
padding: 8px;
max-height: 110px;
overflow: hidden;
text-overflow: ellipsis;
line-height: 1.4em;
}
我只想显示 3 行<ion-text>
. 如果它不再是那么我想显示一个省略号,以便用户可以单击它以查看更多信息。但是,我上面的代码似乎没有以省略号显示 HTML。不知道我错过了什么。任何建议都会很有用。
解决方案
试试这个..这里nowrap
将确保文本永远不会换行到下一行并添加!important
到ellipsis
.
.message {
white-space: nowrap !important;
width: 150px !important;
overflow: hidden !important;
text-overflow: ellipsis !important;
color: var(--ion-color-default-shade) !important;
}
希望这可以帮助.. :)
推荐阅读
- php - 如何在环境之间分隔 PHP $_SESSION 变量?
- swift - 静态变量的 Self.XXX 是什么意思
- javascript - Selenium 不检索动态生成的 html
- reactjs - 如何在下拉列表中显示数据中的选定选项?
- angular - Angular 7 应用程序的 CROSS 起源问题
- java - excel中一列的最后一行使用POI for selenium-java
- linux - 操作给定命令的系统时间
- python - 为什么在 Python 中创建命名元组对象后无法读取“类型名”
- hibernate - 引起:java.lang.IllegalArgumentException:org.hibernate.hql.internal.ast.QuerySyntaxException:意外令牌:近线
- sql - 当使用触发器在 Student 表中插入 1 行时,我需要在 Student_Fee 表中创建 3 行