突破

时间:2017-10-02 12:47:59

标签: html css asp.net-mvc

所以,我正在从我的数据库中显示一个表到我的视图。

@model IEnumerable<test1.Models.Malfunction>
@{ 
ViewBag.Title = "Malfunctions";
}

<h2>Malfunctions</h2>

<table id="customers" class="table table-bordered table-hover">
<thead>
    <tr>
        <th>ID</th>
        <th>Description</th>
        <th>Date Reported</th>
        <th>Customer</th>
        <th>Movie</th>
    </tr>
</thead>
<tbody>
    @foreach (var malfunction in Model)
    {
        <tr>
            <td>@malfunction.Id</td>
            <td>@malfunction.ReportDescription</td>
            <td>@malfunction.DateReported</td>
            <td>@malfunction.Customer</td>
            <td>@malfunction.Movie</td>
        </tr>
    }
</tbody>
</table>

此属性:

<td>@malfunction.ReportDescription</td>

可以包含大量文本,如果太长则会与下一个属性重叠:

<td>@malfunction.DateReported</td>

我想要做的是在达到单元格宽度后断行,这样它就不会与DateReported中的文本重叠。

1 个答案:

答案 0 :(得分:4)

添加:

td {
  word-break: break-all;
}

Fiddle