我有这个单元格内容:

<td style="max-width:200px;" class="sorting_1">
<i class="fa fa-circle text-success"></i>
<span style="width: 200px;">
    Публикация: "The Myth of Ponce de León and the Fountain of Youth"
</span>

<div class="mt-1">
    <span class="text-small text-muted">
        ID: 23843933046690590
    </span>
</div>
</td>


但是span不会获得200px的宽度,而是会扩展到400+ px-http://joxi.ru/823BXGpH9ZdEMm

我应该怎么做才能将宽度限制为200px并在此单元格中自动换行?

最佳答案

您需要添加display: blockdisplay: inline-block



.maxWidth {
  width: 200px;
  display: inline-block;
}

<td style="max-width:200px;" class="sorting_1">
<i class="fa fa-circle text-success"></i>
<span class="maxWidth">
    Публикация: "The Myth of Ponce de León and the Fountain of Youth"
</span>

<div class="mt-1">
    <span class="text-small text-muted">
        ID: 23843933046690590
    </span>
</div>
</td>

关于html - 数据表中的自动换行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59628600/

10-14 14:35