html - 如何使大量文本适合 html 表格单元格

标签 html css angular

我在 Angular/html/css 中创建了一个包含单元格的表格,并且我的单元格必须能够容纳大量文本。我的问题是文本会溢出单元格,我需要它正好适合里面,这样看起来就不错。

enter image description here

这是我的 Angular html 代码:

.theTable {
  font-family: arial, sans-serif;
  border-collapse: collapse;
  width: 100%;
}

td,
th {
  max-width: 450px;
  width: 200%;
  border: 2px solid #9e9e9e;
  text-align: left;
  padding: 15px;
  font-size: 2vh;
}

td {}

tr:nth-child(even) {
  background-color: #d3d3d3;
}
<div class="theTable">
  <table>
    <thead>
      <tr>
        <th>Id</th>
        <th>Name</th>
        <th>ErrorMessage</th>
        <th>StackTrace</th>
      </tr>
    </thead>
    <tr *ngFor="let item of ListOfStuff">
      <td>{{item.id}}</td>
      <td>{{item.automatedTestName}}</td>
      <td>{{item.errorMessage}}</td>
      <td>{{item.stackTrace}}</td>
    </tr>
  </table>
</div>

最佳答案

尝试在您的td中使用[word-wrap:break-word]

td {
  word-wrap: break-word
  width: 200px;
}

关于html - 如何使大量文本适合 html 表格单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49168774/

相关文章:

php - 是否可以将 HTML 表中的数据发布到另一个 PHP 页面?

css - 一个接一个地为 SCSS mixin 使用多个参数

angular - Ionic 2 - 如何处理后退按钮

html - 是否可以在有 Angular 形式内放置粘性 div?

html - Firefox 浏览器中的未知样式表

html - 调整列表项上背景 Sprite 图像的大小

javascript - z-index 不适用于嵌套绝对元素

javascript - 底部的 Owl Carousel 进度条?

css - 添加带有元素 X、Y 坐标的工具提示

angular - 编写更清洁的 Promise 完成闭包