html - CSS 样式在第一行剪切文本并且不显示 VueJS 应用程序上的所有内容

标签 html css vue.js

我的目标是显示最多 5 行的文本以适合卡片,然后能够在其下方放置一个页脚。我确实制作了样式并且它在一个文件中工作以测试代码,但是当我将它放在我的完整页面上时它就不起作用了。文本被剪裁在第一行。

enter image description here

<template>
  <div>
    <md-card>
      <md-toolbar :md-elevation="1">
        <span class="md-title">{{obra.nome}}</span>
      </md-toolbar>

      <md-card-content>
        <md-list>
          <md-list-item>
            <attr>
              Data início
              <attr-content>{{obra.dataInicio}}</attr-content>
            </attr>
          </md-list-item>
          <md-list-item>
            <attr>
              Área
              <attr-content>{{obra.area}} m2</attr-content>
            </attr>
          </md-list-item>
          <md-list-item>
            <attr>
              Dados gerais
              <attr-content>
                this text is not showed completely
                asdasdasdasd
                asdasdasdasddasdasda
                asdasdasd
              </attr-content>
            </attr>
          </md-list-item>
        </md-list>
      </md-card-content>
    </md-card>
  </div>
</template>

<script>
export default {
  name: "CardObra",
  props: {
    obra: Object
  }
};
</script>

<style scoped>
.md-card {
  width: 320px;
  height: 500px;
  margin: 16px;
  vertical-align: top;
}

.md-list {
  padding: 10px;
  overflow: visible;
}

.md-card-content {
  padding: 0px;
}

attr {
  font-size: 20px;
  font-family: "Helvetica";
  color: gray;
}

attr-content {
  margin-top: 3px;
  display: block;
  color: black;
  font-weight: bold;

  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
}

</style>

最佳答案

在文本的父级添加这个

div {
  word-wrap: break-word;
}

如果没有更多的空间留给下一个单词,这将使句子中断,并且它将转到新行。您可以阅读更多相关信息 here

关于html - CSS 样式在第一行剪切文本并且不显示 VueJS 应用程序上的所有内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58783207/

相关文章:

javascript - 带有 javascript 变量的多个 css 类

javascript - 当由同一事件触发时,具有相同持续时间的 CSS3 动画在不同时间结束

javascript - Vue.JS 数据属性未定义

html - PHP HTML-Email结果中随机出现感叹号

javascript - 刷新div内的php脚本

javascript - 如何在页面上的网页元素之间绘制连接线

javascript - Vue.js |在动态构建的数组中创建新的键+值($ajax)

Vue.js:服务器端应用程序的全局基础 URL

php - HTML5 Audio Element "src = get.php 不能跳过位置

html - 导航要左对齐