如何使 Vuetify v-card-text 单行?

Bea*_* 30 6 html css vue.js vuetify.js

我正在使用 vuetify v-card,我需要应用省略号 css,以便它保持单行,并且...在超过时出现。

我使用了以下 css 属性:

.headerClass {
   white-space: nowrap !important;
   width: 95px;
   word-break: normal!important;
   overflow: hidden !important;
   text-overflow: ellipsis !important;
}
Run Code Online (Sandbox Code Playgroud)

这是我的v-card-title

<v-card-title class="body-2 pl-2 headerClass">{{data}}</v-card-title>
Run Code Online (Sandbox Code Playgroud)

我什至应用了文本截断,但没有任何反应

Han*_*mos 7

您可以将文本包装到 html 块元素中以进行工作

<v-card-title class="body-2 pl-2">
    <div class="headerClass">
        {{data}}
    </div>
</v-card-title>
Run Code Online (Sandbox Code Playgroud)

CSS:

.headerClass{
    white-space: nowrap ;
    word-break: normal;
    overflow: hidden ;
    text-overflow: ellipsis;
}
Run Code Online (Sandbox Code Playgroud)

  • 当然!`.v-card__title` 具有 `display flex` 和 `text-overflow: ellipsis` 不适用于 Flex 容器。 (5认同)
  • 嗯,这个成功了。你能解释一下为什么吗?我的方法有什么问题? (2认同)