How to trim content of element and put “…” if the characters go over a certain limit?

后端 未结 3 748
甜味超标
甜味超标 2021-01-05 19:04

I would like to trim a part of the if it is too long. This will make sure the table doesn\'t get messed up. All the data in the following table is re

3条回答
  •  旧巷少年郎
    2021-01-05 19:07

    You might be able to use the CSS text-overflow: ellipsis property.

    According to this compatibility table, it is supported by all major browsers.


    Based on this answer, it looks like you also need to define table-layout: fixed on the table, and overflow: hidden and white-space: nowrap on the cells. The fixed table layout will also require you to adjust your column widths explicitly.

提交回复
热议问题