【发布时间】:2015-01-09 20:26:54
【问题描述】:
我整个上午都在为这个 CSS 问题苦苦挣扎,但似乎没有任何进展。
基本上,我有一个水平滚动表,我使用了 Bootstrap 响应表,并且刚刚删除了媒体查询,因此它可以在所有屏幕尺寸下水平滚动。我正在使用 Angular 的 ng-repeat 循环遍历标题数组和应用于这些标题的数据,并且我希望第一列保持不变。我的 HTML 如下:
<div id="table" class="table-responsive">
<table class="table table-bordered">
<tr>
<th ng-repeat="header in tableHeaders" ng-show="header.show" ng-class="'column-' + $index">
<a ng-click="sortThis(header.name, $index)">
<span class="glyphicon glyphicon-chevron-down" aria-hidden="true" ng-show="sortParam !== header.name"></span>
<span class="glyphicon glyphicon-chevron-" aria-hidden="true" ng-show="sortParam === header.name"></span>
</a> {{header.name}}
<span ng-show="!$first">
<a ng-click="toggleColumn(header, $index)">X</a>
</span>
</th>
</tr>
<tr ng-repeat="row in tableData track by $index">
<td ng-repeat="point in row | orderObjectBy:tableSort track by $index" ng-show="point.show" ng-class="'column-' + $index">{{point.name}}</td>
</tr>
</table>
</div>
我让表格水平滚动,我想冻结第一列。现在,如果有帮助的话,每一列都有自己的类。有什么想法吗?
【问题讨论】:
-
我也在制定一个指令来执行此操作,并且发现这个 jQuery 示例很有用 link。该指令作为属性应用于表格元素,不需要列上的特殊类/属性。
标签: javascript html css angularjs twitter-bootstrap