2016-03-08 26 views
0

我一直在努力寻找一种能够对表格进行排序和调整大小并找到Tablesorter jquery插件(mottie folk)的方法。Hide/Cap/Trim Table Width 100% - Tablesorter

这似乎做的一切我想做的事情时,文本一行

style="text-overflow: ellipsis; white-space: nowrap;" 

然后熄灭页面时除外。这张桌子的宽度是100%,我不想这样做。

是他们的一种方式来阻止导致页面内容去超过100%

代码:

<!DOCTYPE html> 
<html> 
<head> 
    <meta charset="utf-8"> 

     <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.1/jquery.js"></script> 

     <!--http://mottie.github.io/tablesorter/--> 

     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.25.5/css/theme.blue.min.css"> 
     <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.25.5/js/jquery.tablesorter.js"></script> 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.25.5/js/jquery.tablesorter.widgets.js"></script> 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.25.5/js/widgets/widget-resizable.min.js"></script> 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.25.5/js/widgets/widget-storage.min.js"></script> 


    <style id="css">th.tablesorter-header.resizable-false { 
    background-color: #e6bf99; 
} 
/* ensure box-sizing is set to content-box, if using jQuery versions older than 1.8; 
this page is using jQuery 1.4 */ 
*, *:before, *:after { 
    -moz-box-sizing: content-box; 
    -webkit-box-sizing: content-box; 
    box-sizing: content-box; 
} 
</style> 

<script id="js">$(function() { 

    $('.full-width-table').tablesorter({ 
     theme : 'blue', 
     // initialize zebra striping and resizable widgets on the table 
     widgets: [ 'zebra', 'resizable', 'stickyHeaders' ], 
     widgetOptions: { 
      resizable: false, 
      // These are the default column widths which are used when the table is 
      // initialized or resizing is reset; note that the "Age" column is not 
      // resizable, but the width can still be set to 40px here 
      resizable_widths : [ '10%', '10%', '40px', '10%', '100px' ] 
     } 
    }); 

});</script> 
</head> 
<body> 

<div id="main"> 

    <div id="demo"> 

<table class="full-width-table"> 
    <thead> 
     <tr> 
      <th>First Name</th> 
      <th>Last Name</th> 
      <th class="resizable-false">Age</th> 
      <th>Total</th> 
      <th>Discount</th> 
      <th>Date</th> 
     </tr> 
    </thead> 
    <tbody> 
     <tr><td>Peter</td><td>Parker</td><td>28</td><td>$9.99</td><td>20%</td><td>Jul 6, 2006 8:14 AM</td></tr> 
     <tr><td>John</td><td>Hood</td><td>33</td><td>$19.99</td><td>25%</td><td>Dec 10, 2002 5:14 AM</td></tr> 
     <tr><td>Clark</td><td>Kent</td><td>18</td><td>$15.89</td><td>44%</td><td>Jan 12, 2003 11:14 AM</td></tr> 
     <tr><td>Bruce</td><td>Almighty</td><td>45</td><td>$153.19</td><td>44%</td><td>Jan 18, 2001 9:12 AM</td></tr> 
       <tr><td>Bruce</td><td>Evans</td><td>22</td><td>$13.19</td><td>11%</td><td style="text-overflow: ellipsis; white-space: nowrap;">Jan 18, 2007 9:12 AMffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggfff</td></tr> 
    </tbody> 
</table> 
</div> 



</div> 

</body> 
</html> 

enter image description here

回答

0

我知道上悬而未决这个问题的唯一办法更改表中的值。 (除非:使用div构建表格或重新设计表格单元格)
如果将&shy;添加到字符串中,它会告诉浏览器它可以将字符串拆分到新行中。
浏览器无法打破没有空格或字符串“ - ”的字符串。

+0

我从数据库填充表,所以我无法修改内容的动态内容。他们的任何方式来重新创建一个调整大小和可分类的表与divs? – user2229747

+0

这或多或少是一个很长的路,如果它能解决问题并不确定。如果字符串的宽度比整个页面的宽度更大,则必须告诉浏览器添加中断的位置。 (也许通过JavaScript读取字符串,将其拆分,添加­,粘贴并放回表格中) –

相关问题