时间:2021-05-28
本文实例讲述了Bootstrap实现的表格合并单元格。分享给大家供大家参考,具体如下:
1、问题背景
利用Bootstrap设计表格,并且表格需要合并单元格
2、实现源码
<!DOCTYPE html><html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content=""> <title>Bootstrap-表格合并单元格</title> <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.css" rel="external nofollow" /> <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script> <script type="text/javascript" src="https://cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.js" ></script> <style> body,html{ width: 99%; height: 98%; font-family: "微软雅黑"; font-size: 14px; } table{ width: 100%; } </style> <script> </script> </head> <body> <div class="row"> <div class="col-xs-12"> <table class="table table-striped"> <tr> <td> <label for="stuNo">学号:</label> <input type="text" id="stuNo" /> <div class="btn-group" style="width: 157px; height: 26px;"> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" style="width: 157px; height: 26px;"> 班级 </button> <ul class="dropdown-menu" role="menu"> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >一班</a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >二班</a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >三班</a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >四班</a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >五班</a></li> </ul> </div> <button type="button" class="btn btn-primary">查询</button> <button type="button" class="btn">重置</button> </td> </tr> </table> </div> <div class="col-xs-12"> <div class="col-xs-2"> <table class="table table-striped table-bordered"> <caption>学生表</caption> <thead> <tr> <th>学生</th> <th>学号</th> </tr> </thead> <tbody> <tr> <td>胡思</td> <td>2016010101</td> </tr> <tr> <td>赵四</td> <td>2016010102</td> </tr> <tr> <td>陈诚</td> <td>2016010103</td> </tr> <tr> <td>李磊</td> <td>2016010104</td> </tr> <tr> <td>孙杨</td> <td>2016010105</td> </tr> <tr> <td>李爽</td> <td>2016010106</td> </tr> </tbody> </table> <table class="table table-striped table-bordered"> <caption>学生表</caption> <thead> <tr> <th>学生</th> <th>学号</th> </tr> </thead> <tbody> <tr> <td>胡思</td> <td>2016010101</td> </tr> <tr> <td>赵四</td> <td>2016010102</td> </tr> <tr> <td>陈诚</td> <td>2016010103</td> </tr> <tr> <td>李磊</td> <td>2016010104</td> </tr> <tr> <td>游豪</td> <td>2016010105</td> </tr> </tbody> </table> </div> <div class="col-xs-10"> <table class="table table-striped"> <tr style="text-align: center;"> <td>到校</td> <td>回家</td> <td>距离</td> </tr> <tr style="text-align: center;"> <td colspan="2" style="text-align: center;">222</td> <td rowspan="2" style="width: 200px;"> <div class="col-xs-12"> <table class="table table-striped table-bordered"> <thead> <tr> <th>姓名</th> <th>学号</th> </tr> </thead> <tbody> <tr> <td>胡思</td> <td>2016010101</td> </tr> </tbody> </table> </div> </td> </tr> <tr> <td colspan="2" style="text-align: center;">333</td> </tr> </table> <table class="table table-striped"> <tr style="text-align: center;"> <td>到校</td> <td>回家</td> <td>距离</td> </tr> <tr style="text-align: center;"> <td colspan="2" style="text-align: center;">222</td> <td rowspan="2" style="width: 200px;"> <div class="col-xs-12"> <table class="table table-striped table-bordered"> <thead> <tr> <th>姓名</th> <th>学号</th> </tr> </thead> <tbody> <tr> <td>胡思</td> <td>2016010101</td> </tr> </tbody> </table> </div> </td> </tr> <tr> <td colspan="2" style="text-align: center;">333</td> </tr> </table> <table class="table table-striped"> <tr style="text-align: center;"> <td>到校</td> <td>回家</td> <td>距离</td> </tr> <tr style="text-align: center;"> <td colspan="2" style="text-align: center;">222</td> <td rowspan="2" style="width: 200px;"> <div class="col-xs-12"> <table class="table table-striped table-bordered"> <thead> <tr> <th>姓名</th> <th>学号</th> </tr> </thead> <tbody> <tr> <td>胡思</td> <td>2016010101</td> </tr> </tbody> </table> </div> </td> </tr> <tr> <td colspan="2" style="text-align: center;">333</td> </tr> </table> <table class="table table-striped"> <tr style="text-align: center;"> <td>到校</td> <td>回家</td> <td>距离</td> </tr> <tr style="text-align: center;"> <td colspan="2" style="text-align: center;">222</td> <td rowspan="2" style="width: 200px;"> <div class="col-xs-12"> <table class="table table-striped table-bordered"> <thead> <tr> <th>姓名</th> <th>学号</th> </tr> </thead> <tbody> <tr> <td>胡思</td> <td>2016010101</td> </tr> </tbody> </table> </div> </td> </tr> <tr> <td colspan="2" style="text-align: center;">333</td> </tr> </table> </div> </div> </div> </body></html>3、实现结果
PS:关于bootstrap布局,这里再为大家推荐一款本站的在线可视化布局工具供大家参考使用:
在线bootstrap可视化布局编辑工具:
http://tools.jb51.net/aideddesign/layoutit
希望本文所述对大家基于bootstrap的程序设计有所帮助。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
表格:合并单元格参考示例:合并单元格调用方法:margeCells。如下代码:复制代码代码如下:grid.on("load",onLoad);functiono
在表格中合并单元格这一操作是很常见的也是很实用的,在Excel中将多个单元格合并成一个单元格的操作方法有很多,今天小编就为大家介绍在excel中怎么实现表格合并
在表格中合并单元格这一操作是很常见的也是很实用的,在Excel中将多个单元格合并成一个单元格的操作方法有很多,下面就为大家介绍在excel中怎么实现表格合并
excel合并单元格很容易,但是Excel将多个单元格的内容合并到一个单元格中,这却有点难度的,那么在excel表格中如何将单元格文本合并到一个单元格?下面
excel表格标题居中的方法是: 1、新建excel表格,简单制作一份表格; 2、选择第一行单元格,进行合并单元格操作; 3、在合并单元格中输入标题;