Html 如何使用css固定滚动条的位置
我有一个表:-HTML代码Html 如何使用css固定滚动条的位置,html,css,Html,Css,我有一个表:-HTML代码 <div class="table-scroll"> <table class="my-table" cellpadding="0" cellspacing="0"> <thead> <tr> <th>firstName</th> <th>lastName</th>
<div class="table-scroll">
<table class="my-table" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th>firstName</th>
<th>lastName</th>
<th>age</th>
<th>email</th>
<th>balance</th>
<th>Mode</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in rowCollection" ng-class-even="'striped'">
<td>{{row.Row1}}-{{row.Row2}}</td>
<td>{{row.Row3 != null ? row.Row3 : " "}}</td>
<td><div class="width">{{row.Row4 != null ? row.Row4 : " "}}</div></td>
<td>{{row.Row5 != null ? (row.Row2 >= "50"? row.Row5 : (row.Row5 | date:'dd-MMM-yyyy')) : " "}}</td>
<td>{{row.Row2}}</td>
<td>{{row.Row5}}</td>
</tr>
</tbody>
</table>
</div>
JS代码:-
angular.module('myApp', ['smart-table','lrDragNDrop'])
.controller('mainCtrl', ['$scope', '$timeout',
function ($scope, $timeout) {
var nameList = ['Pierre', 'Pol', 'Jacques', 'Robert', 'Elisa'];
var familyName = ['Dupont', 'Germain', 'Delcourt', 'bjip', 'Menez'];
$scope.isLoading = false;
$scope.rowCollection = [];
function createRandomItem() {
var
firstName = nameList[Math.floor(Math.random() * 4)],
lastName = familyName[Math.floor(Math.random() * 4)],
age = Math.floor(Math.random() * 100),
email = firstName + lastName + '@whatever.com',
balance = Math.random() * 3000;
return {
Row1: firstName,
Row2: lastName,
Row3: age,
Row4: email,
Row5: balance
};
}
$scope.columns=['Row1','Row2','Row3','Row4','Row5'];
for(var i=0;i<50;i++){
$scope.rowCollection.push(createRandomItem());
}
}
]);
angular.module('myApp',['smart-table','lrDragNDrop']))
.controller('mainCtrl',['$scope','$timeout',
函数($scope,$timeout){
变量名称列表=['Pierre','Pol','Jacques','Robert','Elisa'];
var familyName=['Dupont'、'Germain'、'Delcourt'、'bjip'、'Menez'];
$scope.isLoading=false;
$scope.rowCollection=[];
函数createRandomItem(){
变量
firstName=nameList[Math.floor(Math.random()*4)],
lastName=familyName[Math.floor(Math.random()*4)],
年龄=Math.floor(Math.random()*100),
email=firstName+lastName+'@whather.com',
balance=Math.random()*3000;
返回{
第1行:名字,
第2行:姓氏,
第3行:年龄,
第4行:电子邮件,
第5行:平衡
};
}
$scope.columns=['Row1','Row2','Row3','Row4','Row5'];
对于(var i=0;iYou真的应该在此处发布代码,否则用户将不愿意帮助您。您可以通过简单地设置表格的宽度来填充容器div的宽度来实现这一点。请阅读。虽然此代码可能会回答问题,但提供有关此代码为什么和/或如何回答问题的其他上下文可以提高其长期稳定性您可以使用上面的css并尝试
angular.module('myApp', ['smart-table','lrDragNDrop'])
.controller('mainCtrl', ['$scope', '$timeout',
function ($scope, $timeout) {
var nameList = ['Pierre', 'Pol', 'Jacques', 'Robert', 'Elisa'];
var familyName = ['Dupont', 'Germain', 'Delcourt', 'bjip', 'Menez'];
$scope.isLoading = false;
$scope.rowCollection = [];
function createRandomItem() {
var
firstName = nameList[Math.floor(Math.random() * 4)],
lastName = familyName[Math.floor(Math.random() * 4)],
age = Math.floor(Math.random() * 100),
email = firstName + lastName + '@whatever.com',
balance = Math.random() * 3000;
return {
Row1: firstName,
Row2: lastName,
Row3: age,
Row4: email,
Row5: balance
};
}
$scope.columns=['Row1','Row2','Row3','Row4','Row5'];
for(var i=0;i<50;i++){
$scope.rowCollection.push(createRandomItem());
}
}
]);
.my-table tbody, thead {display: inline-block; }
.my-table th {min-width:92px;}