如何在引导模式主体上创建具有固定标题的可滚动表格?

2023-12-23

我尝试了这个,但这不起作用。字段值是动态变化的。所以宽度不固定。

<div class="table-responsive">

    <table class="table table-hover">
  <thead>

      <tr>
     ...

      </tr>
    </thead>

    <tbody style="height:100px;overflow-y:scroll;">
     <tr>
      ...
      </tr>
   </tbody>
    </table>
</div>

HTML

<!-- Large modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-lg">Large modal</button>

<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
              <table id="myTable" class="table fix-head  table-striped">
            <thead>
                <tr id="pp">
                    <th>Column1</th>
                    <th >Column2</th>
                    <th >Column3</th>
                    <th >Column4</th>
                    <th>Column5</th>
                  <th>Column6</th>
                  <th>Column7</th>
                  <th>Column8</th>
                  <th>Column9</th>
                </tr>
            </thead>
            <tbody style="height:110px">
              <tr>
              <td>1</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
               <td>Table cell</td>
               <td>Table cell</td>
               <td>Table cell</td>
                <td>Table cell</td>
            </tr>
            <tr>
              <td>2</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
            </tr>
            <tr>
              <td>3</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
            </tr>
            <tr>
              <td>4</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
            </tr>
            <tr>
              <td>5</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
            </tr>
            <tr>
              <td>6</td>

              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
            </tr>
            <tr>
              <td>7</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
            </tr>
            <tr>
              <td>8</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
              <td>Table cell</td>
            </tr>
            </tbody>
        </table>
    </div>
  </div>
</div>

CSS

table.fix-head>tbody, table {
        display:block;

    }

     table.fix-head>tbody {
        overflow-y: scroll;
        height: 100px;
}
#pp th{

  padding-right:28px;
}
#myTable{
  width:100%;
}

JS

 $(document).ready(function(){
      $('#myModal').on('shown.bs.modal', function () {
        $(this).find('.modal-dialog').css({width:'auto',
                                   height:'auto', 
                                  'max-height':'100%'});
    });
  });

Check DEMO这里 :http://codepen.io/ihemant360/pen/vKjNdm http://codepen.io/ihemant360/pen/vKjNdm

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何在引导模式主体上创建具有固定标题的可滚动表格? 的相关文章

随机推荐

  • 从图像创建视频会对某些图像格式产生黑屏视频[重复]

    这个问题在这里已经有答案了 我正在使用下面的命令从图像创建视频 该命令适用于大多数图像 但对于 png 图像 创建的视频无法播放 我只是得到黑屏 String command new String y f concat safe 0 i s
  • 找不到org.springframework.util.ClassUtils.getMethod并且无法初始化DefaultConversionService

    运行我的应用程序后 它会在控制台中显示以下错误 我研究了这个问题 但它answer https stackoverflow com questions 20851236 spring mvc http status 500 servlet
  • Django 模型管理器是否需要 using=self._db

    在使用 Django 用户模型时 我注意到模型管理器包括using self db作用于数据库时的参数 如果我只使用单个数据库 这有必要吗 什么是using self db除了指定数据库之外 还可以执行其他操作 如果添加另一个数据库 这是否
  • gdb 回溯

    我刚刚尝试过使用 gdb回溯Linux http www backtrack linux org 我必须说这太棒了 我想知道 backtrack 中的 gdb 是如何配置为这样的 当我设置断点时 会打印所有寄存器值 堆栈的一部分 数据部分的
  • 适用于 Android 的 Google 环聊 API

    您知道如何将 Google Hangout 集成到 Android 应用程序中吗 我没有看到任何当前可用的 API 使用 WebView 是一种选择吗 目前没有任何内容 我不相信 WebView 版本会起作用 因为环聊需要谷歌安装的相机插件
  • Python Fizzbuzz 循环问题

    我已经搜索了大约一个小时的答案 似乎大多数人都以与我不同的方式编码 fizzbuzz 然而 在尝试了一切方法来找出为什么这个简单的代码不起作用之后 我感到非常沮丧 谁能指出我确定遇到的简单问题 代码运行但只返回值 1 def fizzbuz
  • Android L Nexus 5 上的材料设计

    我的应用程序在 Android L 上崩溃 但在 Android Kitkat 上运行 布局上也没有 RippleDrawable 这是异常和布局 XML 布局
  • ocaml 命令行找不到“topfind”

    我已经安装了顶级 并且有 OCAML TOPLEVEL PATH 设置 export OCAML TOPLEVEL PATH Users smcho opam system lib toplevel 我检查该目录是否存在 并且有一个文件to
  • 在 strpos() 的字符串中使用正则表达式

    我想让脚本搜索 open email msg 不同的电子邮件将有不同的信息 但格式相同 如下所示 我并没有真正使用正则表达式太多 但我想做的是每当我用它来搜索字符串时 它都会搜索 标题 标题数据 类别 类别数据 我问因为我不认为类似的事情
  • 无法找到 Python PIL 库。Google App Engine

    完美安装了Google App Engine SDK Python 2 6 想要进入图像并在本地进行测试 已安装 PIL 安装了Python 然后运行了PIL安装 这次成功了 事情看起来不错 但尝试进行本地主机图像处理 给出 NotImpl
  • Node Puppeteer, page.on( "request" ) 抛出“请求已处理!”

    我在用着puppeteer extra https www npmjs com package puppeteer extra和 node js 来迭代多个 url 我试图拦截一些资源类型以在每次迭代时加载 并收到以下错误 PS C Use
  • ios 中的阴影

    iOS 中如何去掉物体的阴影 My object is UIImageView and i want to drop an elliptical shadow Please refer image for reference 最好使用另一张
  • 使一个流的输出成为另一个流的输入的最佳方法是什么

    我想知道除了使用字节缓冲区和循环之外 是否有更好 内置的方法从一个流读取并将其写入另一个流 在 NET 中 通常 这样做是为了将转换应用于流并将其继续移动 在本例中 我正在加载一个文件 将其放入 deflate 流并将其写入文件 为简单起见
  • AMD(特别是 RequireJs)如何处理跨多个模块的依赖关系

    我有一个调用 require 的主初始化脚本 其中一个依赖项是实用程序框架 但我通过 require 指定的其他一些模块本身也已将此框架定义为依赖项 例如 init js require module a module b module c
  • 删除了方法的 C++ 类可以轻松复制吗?

    我希望类 B 继承类 A 的除少数方法之外的所有方法 假设它是可简单复制的 并且仍然可简单复制 在 C 11 中我可以删除方法 举个例子 class A trivially copyable private stuff here publi
  • 用于奇异控制流的 ES6 Promise 模式

    ES6 Promise 很棒 到目前为止 调整我的想法很容易 回调习惯用法 我发现它自然地鼓励更多的模块化代码 并且 当然错误处理更加清晰 但有几次我遇到了看起来不像 的心流情况 可以很容易地从节点返回到承诺 也许就是这样 但也许我只是对答
  • 如何在 VS Code 设置中为 VS Code 进程指定环境变量?

    我发现这两种方法来添加环境变量 添加环境变量terminal integrated env osx对于终端 添加环境变量launch json用于调试 但 VSCode Process 没有类似的配置选项 一些插件经常需要访问特定的环境变量
  • C++ 中的 rand() 和 srand()

    C 中生成随机数的基础是什么 这背后有什么逻辑或者原理吗 生成的数字是完全随机的吗 假设我正在运行这个程序 include
  • 在javascript中获取元数据属性

    我在从元标记检索信息时遇到问题 我正在尝试从网站获取 img src 但不太明白 这是我正在尝试做的一个例子 var image document querySelector meta property og image getAttrib
  • 如何在引导模式主体上创建具有固定标题的可滚动表格?

    我尝试了这个 但这不起作用 字段值是动态变化的 所以宽度不固定 div class table responsive table class table table hover thead tr tr thead tbody style h