1

I have created an application in angularjs using ngtable, since I need the table head to be fixed I tried using position:fixed; so that the head is fixed but the problem is that now the body and head overlaps also the width of the table is not expanding

My code is as given below

JSFiddle

html

<div ng-controller="IndexCtrl">
    <table border="1" ng-table="mytable" id="myTable" class="ScrollArea">
        <tbody ng-repeat="peop in $groups">
            <tr ng-repeat="people in peop.data">
                <td sortable="id" data-title="'Id'">{{people.id}}</td>
                <td sortable="desig" data-title="'Desig'">{{people.desig}}</td>
                <td sortable="name" data-title="'Name'">{{people.name}}</td>
                <td sortable="place" data-title="'Place'">{{people.place}}</td>
            </tr>
        </tbody>
    </table>
</div>

css

#myTable thead
{
    position:fixed;
}
.ScrollArea
{
    display: block;
    height: 200px;
    overflow-y: scroll;
}
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Alex Man
  • 4,746
  • 17
  • 93
  • 178

2 Answers2

1

you have to remove position fixed in #myTable thead

and remove display: block; in .scrollArea.

0

Add cellpadding to change width of the table. and add top/bottom to the thead to solve the overlap.

TM Dinesh
  • 210
  • 3
  • 13