源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

bootstrap表格内容过长时用省略号表示的解决方法

  • 时间:2020-05-28 06:57 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:bootstrap表格内容过长时用省略号表示的解决方法
首先 ,bootstrap中当td内容超过我给的固定宽度时,省略号代替的代码如下:
<table class="table table-bordered">
   <thead>
     <tr>
       <th class="center" style='width:38%;'>商品名称</th>
       <th class="center" style='width:36%;'>详细介绍</th>
       <th class="center" style='width:22%;'>购买数量</th>
     </tr>
   </thead>
   <tbody id="tbody">
     <tr>
      <td>自由行机票享超值优惠</td>
      <td>随心所欲安排行程</td>
      <td>70</td>
    </tr>
    <tr>
      <td>自由行机票享超值优惠</td>
      <td>随心所欲安排行程</td>
      <td>70</td>
    </tr>   
    <tr>
      <td>自由行机票享超值优惠</td>
      <td>随心所欲安排行程</td>
      <td>70</td>
    </tr>            
   </tbody>               
 </table>
.table tbody tr td{
   overflow: hidden; 
   text-overflow:ellipsis; 
   white-space: nowrap; 
 }
移动端模拟器显示效果是这样的。不是很舒服,完全没按我给他的宽度显示,全靠内容挤出来的。 [img]http://files.jb51.net/file_images/article/201711/2017112115232740.png[/img]   解决方法:
<table class="table table-bordered" style='table-layout:fixed;'>
也就是添加样式
table{
 table-layout:fixed;
}
效果出现: [img]http://files.jb51.net/file_images/article/201711/2017112115232741.png[/img] table-layout用来显示表格单元格、行、列的算法规则。值 描述 automatic 默认。列宽度由单元格内容设定。 fixed 列宽由表格宽度和列宽度设定。 inherit 规定应该从父元素继承 table-layout 属性的值。 [b]总结[/b] 以上所述是小编给大家介绍的bootstrap表格内容过长时用省略号表示的解决方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对编程素材网网站的支持!
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部