简单教程
提交运行
代码编辑器:
<!DOCTYPE html> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://cdn.bootcss.com/foundation/5.5.3/css/foundation.min.css"> <script src="https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script> <script src="https://cdn.bootcss.com/foundation/5.5.3/js/foundation.min.js"></script> <script src="https://cdn.bootcss.com/foundation/5.5.3/js/vendor/modernizr.js"></script> <h2>响应式表格</h2> <p>在 div 元素上添加 overflow-x:auto 样式,让它支持响应式</p> <p>重置浏览器窗口查看效果 (如果空间不足会出现垂直滚动条)</p> <div class="responsive" style="overflow-x:auto"> <table> <thead> <tr> <th>Firstname</th> <th>Lastname</th> <th>Email</th> <th>City</th> <th>Age</th> <th>Country</th> </tr> </thead> <tbody> <tr> <td>John</td> <td>Doe</td> <td>john@example.com</td> <td>New York</td> <td>35</td> <td>USA</td> </tr> <tr> <td>Mary</td> <td>Moe</td> <td>mary@example.com</td> <td>Chicago</td> <td>51</td> <td>USA</td> </tr> <tr> <td>July</td> <td>Dooley</td> <td>july@example.com</td> <td>San Francisco</td> <td>38</td> <td>USA</td> </tr> </tbody> </table> </div>
运行结果: