jquery – 响应式引导数据可以在正确的位置折叠列

前端之家收集整理的这篇文章主要介绍了jquery – 响应式引导数据可以在正确的位置折叠列前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用Datatables.net最新的数据表和引导。我想我的问题是:Datatables响应引导使用什么来检测溢出,因为它显然不是父宽度。

这是我的结果:

这是一个很直接的问题。如果我减少我的窗口的宽度1更多的像素,列将最终崩溃。如果我再扩展它,它返回到这个状态。我想防止从父引导面板溢出。我已经删除了引导网格div(row / col-xs-12等)以消除潜在问题,但一旦解决了(或者我更好地理解问题),我打算使用引导网格系统。

这是一个完美复制问题的plunkr(折叠运行视图):
http://plnkr.co/edit/tZxAMOHmdoHNHrzhP5tR?p=preview

  1. <!DOCTYPE html>
  2.  
  3. <html>
  4. <head>
  5. <title>Tables - PixelAdmin</title>
  6. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"/>
  7. <link rel="stylesheet" href="http://cdn.datatables.net/plug-ins/a5734b29083/integration/bootstrap/3/dataTables.bootstrap.css"/>
  8. <link rel="stylesheet" href="http://cdn.datatables.net/responsive/1.0.2/css/dataTables.responsive.css"/>
  9. <style>
  10. body {
  11. font-size: 140%;
  12. }
  13.  
  14. table.dataTable th,table.dataTable td {
  15. white-space: nowrap;
  16. }
  17. </style>
  18. </head>
  19.  
  20. <body style="padding-top: 40px;">
  21.  
  22. <div class="panel panel-primary" style="margin: 51px; padding: 0;">
  23. <div class="panel-heading">
  24. <h3 class="panel-title">Panel title</h3>
  25. </div>
  26. <div class="panel-body" style="padding: 0;">
  27. <div style="width: 100%; border: 1px solid red;">
  28. <table id="example" class="table table-striped table-hover dt-responsive" cellspacing="0" width="100%">
  29. <thead>
  30. <tr>
  31. <th>Name</th>
  32. <th>Position</th>
  33. <th>Office</th>
  34. <th>Extn.</th>
  35. <th>Start date</th>
  36. <th>Salary</th>
  37. </tr>
  38. </thead>
  39. </table>
  40. </div>
  41. </div>
  42. </div>
  43.  
  44. <script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
  45. <script type="text/javascript" language="javascript" src="//cdn.datatables.net/1.10.3/js/jquery.dataTables.min.js"></script>
  46. <script type="text/javascript" language="javascript" src="//cdn.datatables.net/responsive/1.0.2/js/dataTables.responsive.js"></script>
  47. <script type="text/javascript" language="javascript" src="//cdn.datatables.net/plug-ins/a5734b29083/integration/bootstrap/3/dataTables.bootstrap.js"></script>
  48.  
  49. <script>
  50. $(document).ready(function () {
  51. $('#example')
  52. .dataTable({
  53. "responsive": true,"ajax": 'data.json'
  54. });
  55. });
  56. </script>
  57.  
  58. </body>
  59. </html>

解决方法

在表开始前添加具有“表响应”类的Div,并从表标记删除width =“100%”,
  1. <div class="panel panel-primary" style="margin: 50px;">
  2. <div class="panel-heading">
  3. <h3 class="panel-title">Panel title</h3>
  4. </div>
  5. <div class="panel-body">
  6. <div style="width: 100%; padding-left: -10px; border: 1px solid red;">
  7. <div class="table-responsive"> // add this div
  8. <table id="example" class="table table-striped table-hover dt-responsive display nowrap" cellspacing="0"> // remove width from this
  9. <thead>
  10. <tr>
  11. <th>Name</th>
  12. <th>Position</th>
  13. <th>Office</th>
  14. <th>Extn.</th>
  15. <th>Start date</th>
  16. <th>Salary</th>
  17. </tr>
  18. </thead>
  19. </table>
  20. </div>
  21. </div>
  22. </div>

猜你在找的jQuery相关文章