2016-06-10 51 views
0

我有日历与左侧和右侧的用户列表 - 日期与细胞。顶部我需要修复日期时滚动页面底部。我不知道我怎么能做到这一点,因为我有<table>与主要<table>overflow: scroll日期,因为我需要滚动和固定左侧用户。固定磁贴水平和垂直滚动表

如何修复<thead>顶部日期滚动到页面底部?现在简单position: absolute;,因为我有嵌套表和overflow: scroll;。在两个不同的表格中将日期分解为thead和tbody上的日期?并捕获事件scroll并将其应用于其他表?

的jsfiddle - https://jsfiddle.net/p69j0L5h/2/

附:在实际情况中,所有的单元格都是相等的(大约宽度和高度)。这仅仅是一个例子。

+0

是否有这样的结构要求?嵌套表格非常复杂,对行的“冻结”(你想要的日期行的效果)可以完成,但它似乎是一个比我提出的更不方便和低效的解决方案。 – MassDebates

+0

有(相当老)jquery插件用于此目的。 https://plugins.jquery.com/table-scroll/ –

回答

0

只需使用

//makes thead stay in fixed position 
 
thead { 
 
position: fixed; 
 
} 
 

 
//makes td 100px wide 
 
td { 
 
width: 100px; 
 
} 
 

 
//makes scroll bar on bottom appear up top 
 
table { 
 
height: 200px; /*think that 100% would work too*/ 
 
}

+0

这是什么?请给我jsfiddle – Luntegg

0

随着发生在你的HTML布局,我可以达到你想要的东西!但我不确定这是否正确。

的HTML看起来像这样:

<div ng-controller="MainCtrl" class="container main"> 
    <table class="table table-bordered"> 
    <thead> 
     <tr class="fixed"> 
     <th>blank space</th> 
     <th ng-repeat="date in dates"> 
      {{date}} 
     </th> 
     </tr> 
    </thead> 

    </table> 
    <table class="table table-bordered" style="margin-top:50px"> 
    <tbody style="margin-top:30px"> 
     <tr ng-repeat="user in users"> 
     <td>{{user}}</td> 
     <td ng-repeat="date in dates"></td> 
     </tr> 
    </tbody> 
    </table> 
</div> 

我创建了相同的小提琴:https://jsfiddle.net/gpa5v9L7/

+0

水平滚动和溢出位置在哪里? – Luntegg

+0

这里你去:https://jsfiddle.net/u9bwqcht/ – pix1289

+0

主表中的单元格不动 – Luntegg