因为bootstrap自带的固定列效果满足不了公司需求,所以借助fixed-table这个插件完成了iview固定列的效果

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>左右两侧固定列,中间内容可以横向拖动</title>
    <link rel="stylesheet" href="css/fixed-table.css" />
    <script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
    <script src="js/fixed-table.js"></script>
    <style>
        .fixed-table-box{
            width: 800px;
            margin: 50px auto;
        }
        .fixed-table-box>.fixed-table_body-wraper{/*内容了表格主体内容有纵向滚动条*/
            max-height: 260px;
        }
        
        .fixed-table_fixed>.fixed-table_body-wraper{/*为了让两侧固定列能够同步表格主体内容滚动*/
            max-height: 240px;
        }
        .w-150{
            width: 150px;
        }
        .w-120{
            width: 120px;
        }
        .w-300{
            width: 300px;
        }
        .w-100{
            width: 100px;
        }
        .btns{
            text-align: center;
        }
        .btns button{
            padding: 10px 20px;
        }
    </style>
</head>
<body>
    <div class="fixed-table-box row-col-fixed">
        <!-- 表头 start -->
        <div class="fixed-table_header-wraper">
            <table class="fixed-table_header" cellspacing="0" cellpadding="0" border="0">
                <thead>
                    <tr>
                        <th class="w-150" data-fixed="true"><div class="table-cell">日期</div></th>
                        <th class="w-120"><div class="table-cell">姓名</div></th>
                        <th class="w-120"><div class="table-cell">省份</div></th>
                        <th class="w-120"><div class="table-cell">市区</div></th>
                        <th class="w-300"><div class="table-cell">地址</div></th>
                        <th class="w-120"><div class="table-cell">邮编</div></th>
                        <th class="w-100" data-fixed="true" data-direction="right"><div class="table-cell">操作</div></th>
                    </tr>
                </thead>
            </table>
        </div>
        <!-- 表头 end -->
        <!-- 表格内容 start -->
        <div class="fixed-table_body-wraper">
            <table class="fixed-table_body" cellspacing="0" cellpadding="0" border="0">
                <tbody>
                    <tr>
                        <td class="w-150"><div class="table-cell"> 2016-05-03</div></td>
                        <td class="w-120"><div class="table-cell">王小虎</div></td>
                        <td class="w-120"><div class="table-cell">上海</div></td>
                        <td class="w-120"><div class="table-cell">普陀区</div></td>
                        <td class="w-300"><div class="table-cell">上海市普陀区金沙江路 1518 路</div></td>
                        <td class="w-120"><div class="table-cell">200333</div></td>
                        <td class="w-100">
                            <div class="table-cell">
                                <a href="###">查看</a>
                                <a href="###">编辑</a>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="w-150"><div class="table-cell"> 2016-05-03</div></td>
                        <td class="w-120"><div class="table-cell">王小虎</div></td>
                        <td class="w-120"><div class="table-cell">上海</div></td>
                        <td class="w-120"><div class="table-cell">普陀区</div></td>
                        <td class="w-300"><div class="table-cell">上海市普陀区金沙江路 1518 路</div></td>
                        <td class="w-120"><div class="table-cell">200333</div></td>
                        <td class="w-100">
                            <div class="table-cell">
                                <a href="###">查看</a>
                                <a href="###">编辑</a>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="w-150"><div class="table-cell"> 2016-05-03</div></td>
                        <td class="w-120"><div class="table-cell">王小虎</div></td>
                        <td class="w-120"><div class="table-cell">上海</div></td>
                        <td class="w-120"><div class="table-cell">普陀区</div></td>
                        <td class="w-300"><div class="table-cell">上海市普陀区金沙江路 1518 路</div></td>
                        <td class="w-120"><div class="table-cell">200333</div></td>
                        <td class="w-100">
                            <div class="table-cell">
                                <a href="###">查看</a>
                                <a href="###">编辑</a>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="w-150"><div class="table-cell"> 2016-05-03</div></td>
                        <td class="w-120"><div class="table-cell">王小虎</div></td>
                        <td class="w-120"><div class="table-cell">上海</div></td>
                        <td class="w-120"><div class="table-cell">普陀区</div></td>
                        <td class="w-300"><div class="table-cell">上海市普陀区金沙江路 1518 路</div></td>
                        <td class="w-120"><div class="table-cell">200333</div></td>
                        <td class="w-100">
                            <div class="table-cell">
                                <a href="###">查看</a>
                                <a href="###">编辑</a>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="w-150"><div class="table-cell"> 2016-05-03</div></td>
                        <td class="w-120"><div class="table-cell">王小虎</div></td>
                        <td class="w-120"><div class="table-cell">上海</div></td>
                        <td class="w-120"><div class="table-cell">普陀区</div></td>
                        <td class="w-300"><div class="table-cell">上海市普陀区金沙江路 1518 路</div></td>
                        <td class="w-120"><div class="table-cell">200333</div></td>
                        <td class="w-100">
                            <div class="table-cell">
                                <a href="###">查看</a>
                                <a href="###">编辑</a>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="w-150"><div class="table-cell"> 2016-05-03</div></td>
                        <td class="w-120"><div class="table-cell">王小虎</div></td>
                        <td class="w-120"><div class="table-cell">上海</div></td>
                        <td class="w-120"><div class="table-cell">普陀区</div></td>
                        <td class="w-300"><div class="table-cell">上海市普陀区金沙江路 1518 路</div></td>
                        <td class="w-120"><div class="table-cell">200333</div></td>
                        <td class="w-100">
                            <div class="table-cell">
                                <a href="###">查看</a>
                                <a href="###">编辑</a>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="w-150"><div class="table-cell"> 2016-05-03</div></td>
                        <td class="w-120"><div class="table-cell">王小虎</div></td>
                        <td class="w-120"><div class="table-cell">上海</div></td>
                        <td class="w-120"><div class="table-cell">普陀区</div></td>
                        <td class="w-300"><div class="table-cell">上海市普陀区金沙江路 1518 路</div></td>
                        <td class="w-120"><div class="table-cell">200333</div></td>
                        <td class="w-100">
                            <div class="table-cell">
                                <a href="###">查看</a>
                                <a href="###">编辑</a>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="w-150"><div class="table-cell"> 2016-05-03</div></td>
                        <td class="w-120"><div class="table-cell">王小虎</div></td>
                        <td class="w-120"><div class="table-cell">上海</div></td>
                        <td class="w-120"><div class="table-cell">普陀区</div></td>
                        <td class="w-300"><div class="table-cell">上海市普陀区金沙江路 1518 路</div></td>
                        <td class="w-120"><div class="table-cell">200333</div></td>
                        <td class="w-100">
                            <div class="table-cell">
                                <a href="###">查看</a>
                                <a href="###">编辑</a>
                            </div>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <!-- 表格内容 end -->
        <!-- 固定列 start -->
        <div class="fixed-table_fixed fixed-table_fixed-left">
            <div class="fixed-table_header-wraper">
                <table class="fixed-table_header" cellspacing="0" cellpadding="0" border="0">
                    <thead>
                        <tr>
                            <th class="w-150"><div class="table-cell">日期</div></th>
                        </tr>
                    </thead>
                </table>
            </div>
            
            <div class="fixed-table_body-wraper">
                <table class="fixed-table_body" cellspacing="0" cellpadding="0" border="0">
                    <tbody>
                        <tr>
                            <td class="w-150"><div class="table-cell"> 2016-05-03</div></td>
                        </tr>
                        <tr>
                            <td class="w-150"><div class="table-cell"> 2016-05-03</div></td>
                        </tr>
                        <tr>
                            <td class="w-150"><div class="table-cell"> 2016-05-03</div></td>
                        </tr>
                        <tr>
                            <td class="w-150"><div class="table-cell"> 2016-05-03</div></td>
                        </tr>
                        <tr>
                            <td class="w-150"><div class="table-cell"> 2016-05-03</div></td>
                        </tr>
                        <tr>
                            <td class="w-150"><div class="table-cell"> 2016-05-03</div></td>
                        </tr>
                        <tr>
                            <td class="w-150"><div class="table-cell"> 2016-05-03</div></td>
                        </tr>
                        <tr>
                            <td class="w-150"><div class="table-cell"> 2016-05-03</div></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="fixed-table_fixed fixed-table_fixed-right">
            <div class="fixed-table_header-wraper">
                <table class="fixed-table_header" cellspacing="0" cellpadding="0" border="0">
                    <thead>
                        <tr>
                            <th class="w-100"><div class="table-cell">操作</div></th>
                        </tr>
                    </thead>
                </table>
            </div>
            
            <div class="fixed-table_body-wraper">
                <table class="fixed-table_body" cellspacing="0" cellpadding="0" border="0">
                    <tbody>
                        <tr>
                            <td class="w-100">
                                <div class="table-cell">
                                    <a href="###">查看</a>
                                    <a href="###">编辑</a>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td class="w-100">
                                <div class="table-cell">
                                    <a href="###">查看</a>
                                    <a href="###">编辑</a>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td class="w-100">
                                <div class="table-cell">
                                    <a href="###">查看</a>
                                    <a href="###">编辑</a>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td class="w-100">
                                <div class="table-cell">
                                    <a href="###">查看</a>
                                    <a href="###">编辑</a>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td class="w-100">
                                <div class="table-cell">
                                    <a href="###">查看</a>
                                    <a href="###">编辑</a>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td class="w-100">
                                <div class="table-cell">
                                    <a href="###">查看</a>
                                    <a href="###">编辑</a>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td class="w-100">
                                <div class="table-cell">
                                    <a href="###">查看</a>
                                    <a href="###">编辑</a>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td class="w-100">
                                <div class="table-cell">
                                    <a href="###">查看</a>
                                    <a href="###">编辑</a>
                                </div>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <!-- 固定列 end -->
    </div>
    <div class="btns">
        <button type="button" id="empty_data">清空数据</button>
        <button type="button" id="add_data">添加数据</button>
        <button type="button" id="del_row">删除行</button>
    </div>
    <script>
        //初始化FixedTable
        $(".fixed-table-box").fixedTable();
        //清空表格
        $("#empty_data").on("click", function (){
            $(".fixed-table-box").emptyTable();
        });
        //添加数据
        $("#add_data").on("click", function (){
            $(".fixed-table-box").addRow(function (){
                var html = '';
                for(var i = 0; i < 5; i ++){
                    html += '<tr>';
                    html += '    <td class="w-150"><div class="table-cell"> 2016-05-03</div></td>';
                    html += '    <td class="w-120"><div class="table-cell">王小虎</div></td>';
                    html += '    <td class="w-120"><div class="table-cell">上海</div></td>';
                    html += '    <td class="w-120"><div class="table-cell">普陀区</div></td>';
                    html += '    <td class="w-300"><div class="table-cell">上海市普陀区金沙江路 1518 路</div></td>';
                    html += '    <td class="w-120"><div class="table-cell">200333</div></td>';
                    html += '    <td class="w-100">';
                    html += '        <div class="table-cell">';
                    html += '            <a href="###">查看</a>';
                    html += '            <a href="###">编辑</a>';
                    html += '        </div>';
                    html += '    </td>';
                    html += '</tr>';
                }
                return html;
            });
        });
        //删除指定行
        $("#del_row").on("click", function (){
            $(".fixed-table-box").deleteRow($(".fixed-table-box").children('.fixed-table_fixed-left').children('.fixed-table_body-wraper').find('tr').eq(0));
        });
    </script>
</body>
</html>具体网址忘了存了,有需要的小伙伴可自己查一下~
次案例从一个网站下载,
 
实现效果为:

bootstrap table实现iview固定列的效果的更多相关文章

  1. tableZen maxHeight 解决方案 如果数据条数小于N,不进行高度设置,超过N条,直接设置高度,解决原生iview Table 对于右侧固定列,不能计算出正确数值的解决方案

    tableZen maxHeight 解决方案 如果数据条数小于N,不进行高度设置,超过N条,直接设置高度,解决原生iview Table 对于右侧固定列,不能计算出正确数值的解决方案 if (thi ...

  2. layui table 数据表格固定列的行高和table其他列的行高不一致

    1.问题描述:使用layui的table数据表格,固定某一列,这样表格中数据的宽度超出屏幕宽度时,固定列可以一直显示在屏幕中,不会随着底部滚动栏左右的拖动而变化位置.但是遇到一个问题,就是固定列的行高 ...

  3. bootstrap table表格属性、列属性、事件、方法

    留存一份,原文地址http://bootstrap-table.wenzhixin.net.cn/zh-cn/documentation/ 表格参数 表格的参数定义在 jQuery.fn.bootst ...

  4. 好用的自适应表格插件-bootstrap table (支持固定表头)

    最近工作中找到了一款十分好用的表格插件,不但支持分页,样式,搜索,事件等等表格插件常有的功能外,最主要的就是他自带的冻结表头功能,让开发制作表格十分容易,不过网上大多都是英文文档,第一次使用会比较麻烦 ...

  5. bootstrap table footerFormatter用法 统计列求和 sum、average等

    其实上一篇blog里已经贴了代码,简单解释一下吧: 1.showFooter: true,很重要,设置footer显示: $(cur_table).bootstrapTable({ url: '/et ...

  6. C# Bootstrap table之 分页

    效果如图: 一.声明talbe <div class="container"> <table id="table" class="t ...

  7. [转]C# Bootstrap table之 分页

    本文转自:https://www.cnblogs.com/zhangjd/p/7895453.html 效果如图: 一.声明talbe <div class="container&qu ...

  8. bootstrap-table固定表头固定列

    1.引入 bootstrap依赖于jquery bootstrap-table依赖于bootstrap,所以都需要引入 2. bootstrap-table有两种方式,html.js <tabl ...

  9. 161222、Bootstrap table 服务器端分页示例

    bootstrap版本 为 3.X bootstrap-table.min.css bootstrap-table-zh-CN.min.js bootstrap-table.min.js 前端boot ...

随机推荐

  1. navicat安装与激活

    原文网址:https://www.jianshu.com/p/5f693b4c9468?mType=Group 一.Navicat Premium 12下载 Navicat Premium 12是一套 ...

  2. 随堂小测APP使用体验

    随堂小测APP使用体验 先要去注册账号需要填写用户名.密码.手机号.学号/教师号.学校.专业.即可注册,注册成功后,即可登录APP进,登陆进去以后.会有两个界面,课堂和我的,注册.登录简单,通俗易懂, ...

  3. Spring Boot教程(八)创建含有多module的springboot工程

    创建根工程 创建一个maven 工程,其pom文件为: <?xml version="1.0" encoding="UTF-8"?> <pro ...

  4. LBS 基于位置的服务

    LBS (Location Based Services)基于位置的服务 基于位置的服务,它是通过电信移动运营商的无线电通讯网络(如GSM网.CDMA网)或外部定位方式(如GPS)获取移动终端用户的位 ...

  5. zabbix分布式监控环境搭建

    本次测试主要是在 centos 系统环境实践,测试内容:集群多台服务器资源监控做后续铺垫.zabbix的简介和自身的特点.在这就不阐述了 查询防火墙状态service iptables status停 ...

  6. 转载 用ShadowVolume画模型的影子

    阅读目录(Content) Shadow Volume 包围盒 动态生成包围盒 判断 多光源下的阴影 总结 问题 CSharpGL(48)用ShadowVolume画模型的影子 回到顶部(go to ...

  7. python调用c++类方法(2)

    testpy.cpp: #include<iostream> #include<vector> struct point{ float pointx; float pointy ...

  8. Python深度学习读书笔记-1.什么是深度学习

    人工智能 什么是人工智能.机器学习与深度学习(见图1-1)?这三者之间有什么关系?

  9. day65—angularJS的学习笔记1

    转行学开发,代码100天—2018-05-20 AngularJS的引用示例: <!DOCTYPE html> <html> <head> <title> ...

  10. mybatisProxy

    config.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE configurati ...