当前位置: 首页 > 工具软件 > word-Table > 使用案例 >

table td 内容太长自动换行的实例(word-wrap和word-break的差异)

韦胜泫
2023-12-01

参考文档 :

   table-layout  : http://www.w3school.com.cn/cssref/pr_tab_table-layout.asp

word-wrap 和 word-brak的差异:  http://www.cnblogs.com/2050/archive/2012/08/10/2632256.html


首先:固定table的布局  :
   table-layout: 默认是automatic , fixed  列宽由表格宽度和列宽度设定

选择断句:

     word-wrap:break-word  先换行,如果换行可以后不溢出 td,那么不再截断,否则截断

     word-break: break-all  暴力,不换行直接阶段 


<table class="table table-hover table-bordered" style="table-layout:fixed">
    <thead>
    <tr>
        <th>示例</th>
        <th >Time</th>
    </tr>
    </thead>
    <tbody>
    <?php foreach ($account_list as $account): ?>
    <tr>
        <td style="word-wrap:break-word">{$account['api_example']}</td>
        <td>
            <div>start : {$account['created_at'] ? date('Y-m-d H:i:s', $account['created_at']) : ''}</div>
            <div>&nbsp;end :  {$account['validuntil']}</div>
        </td>
    </tr>
    <?php endforeach ?>
    </tbody>
</table>


 类似资料: