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

参考文档 :

   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>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值