登录  /  注册
首页 > web前端 > js教程 > 正文

Bootstrap实现表格合并单元格示例

小云云
发布: 2018-02-06 14:21:13
原创
3151人浏览过

本文主要和大家介绍bootstrap实现的表格合并单元格,涉及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>
    <p class="row">
      <p class="col-xs-12">
        <table class="table table-striped">
          <tr>
            <td>
              <label for="stuNo">学号:</label>
              <input type="text" id="stuNo" />
              <p 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>
              </p>
              <button type="button" class="btn btn-primary">查询</button>
              <button type="button" class="btn">重置</button>
            </td>
          </tr>
        </table>
      </p>
      <p class="col-xs-12">
        <p 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>
        </p>
        <p 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;">
                <p 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>
                </p>
              </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;">
                <p 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>
                </p>
              </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;">
                <p 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>
                </p>
              </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;">
                <p 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>
                </p>
              </td>
            </tr>
            <tr>
              <td colspan="2" style="text-align: center;">333</td>
            </tr>
          </table>
        </p>
      </p>
    </p>
  </body>
</html>
登录后复制

3、实现结果

相关推荐:

多种情况合并单元格的方法讲解

table合并单元格与img图片铺满整个td的html的方法

JSP中动态合并单元格的实例代码

以上就是Bootstrap实现表格合并单元格示例的详细内容,更多请关注php中文网其它相关文章!

智能AI问答
PHP中文网智能助手能迅速回答你的编程问题,提供实时的代码和解决方案,帮助你解决各种难题。不仅如此,它还能提供编程资源和学习指导,帮助你快速提升编程技能。无论你是初学者还是专业人士,AI智能助手都能成为你的可靠助手,助力你在编程领域取得更大的成就。
相关标签:
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号