Javascript 具有固定标题和固定列的HTML数据表

Javascript 具有固定标题和固定列的HTML数据表,javascript,jquery,html,Javascript,Jquery,Html,我想冻结附加图片中表格的标题和前两列。我尝试了一些插件,但没有达到效果 CSS .outer {position:relative} .inner { overflow-x:scroll; overflow-y:scroll; height: 400px; *width:91%; *margin-left:100px; } HTML <div class='outer'> <div class='inner'>

我想冻结附加图片中表格的标题和前两列。我尝试了一些插件,但没有达到效果

CSS

.outer {position:relative}
.inner {
    overflow-x:scroll;
    overflow-y:scroll;
    height: 400px;
    *width:91%; 
    *margin-left:100px;
}
HTML

<div class='outer'>
    <div class='inner'>
        <table id='MyTable' class='table table-striped table-bordered table-hover dataTable'>
            <thead id='theadMR'></thead>
            <tbody id='tbodyMR'></tbody>
        </table>
    </div>
</div>

位置:固定
将帮助您将
.internal
div的位置设置为固定

.inner{
position: fixed;
top: 0px;
}

尝试使用
位置创建一个类:固定像这样

.fixed {
 position: fixed;
}
然后将其添加到表的标题和要修复的前两列

<div class='outer'>
    <div class='inner'>
      <table id='MyTable' class='table table-striped table-bordered table-hover dataTable'>
        <thead id='theadMR' class='fixed'></thead>
        <tbody id='tbodyMR'></tbody>
      </table>
    </div>
 </div>