gpt4 book ai didi

css - 使第一列始终固定,其余列压缩在表中

转载 作者:行者123 更新时间:2023-11-28 16:21:58 25 4
gpt4 key购买 nike

我有一张 table ,我想在其中始终显示第一列,而其他列则以某种方式将它们自己压在一起,成为其余空间。

我尝试模拟 320 的固定宽度(针对手机尺寸)..

这是我的 plunker:http://plnkr.co/edit/I5Qe21mgGGpMV94bdMl6?p=preview

下面你可以看到所有的代码和CSS..

<!doctype html>
<html ng-app="plunker">

<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.5/slate/bootstrap.min.css" />
<script data-require="angular.js@*" data-semver="1.2.0" src="http://code.angularjs.org/1.2.0/angular.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>

<body>
<div ng:controller="MainCtrl">

<table border="1" style="width: 320px;" class="table table-striped table-hover table-responsive table-bordered">
<thead style="font-weight: bold;">
<tr>
<th ng-repeat="column in columnsTest" ng-if="column.checked" ng-bind="column.id"></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in rows">

<td ng-repeat="column in columnsTest" ng-if="column.checked">
<span class="glyphicon glyphicon-circle-arrow-right" ng-show="column.id === 'Value1'"></span>
{{row[column.id]}}
</td>
</tr>
</tbody>
</table>

<p>Visible Columns:</p>
<br />
<div class="cbxList" ng-repeat="column in columnsTest">
<input type="checkbox" ng-model="column.checked">{{column.id}}
</div>


</div>

<style>
table {
table-layout: fixed;
width: 100%;
font-size: 10px;
}

td {
word-wrap: break-word;
}
</style>



<script>
var app = angular.module('plunker', []);




app.controller('MainCtrl', function($scope) {
$scope.columnsTest = [{
id: 'Value1',
checked: true
}, {
id: 'Value2',
checked: true
}, {
id: 'Value3',
checked: true
}];


$scope.rows = [{
id: 1,
"Value1": 'Thisshouldbeonerow',
"Value2": 2013321,
"Value3": 2012352432423
}];


$scope.columnToggled = function(column) {
$('[data-col-id="' + column.id + '"]').each(function() {
var element = this;
if ($(element).hasClass('ng-hide')) {
$(element).removeClass('ng-hide');
} else {
$(element).addClass('ng-hide');
}
});
};


function updateRow(row) {
for (var i = 0; i < $scope.rows.length; i++) {
if ($scope.rows[i].id === row.id) {
$scope.rows[i] = row;
}
}
}


});
</script>
</body>

</html>

最佳答案

你好,看看这个 plunker

https://plnkr.co/edit/cvJruUG5Eh1n2CJQ0KXZ

.fixed_headers {
width: 750px;
table-layout: fixed;....

进一步检查

关于css - 使第一列始终固定,其余列压缩在表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36640776/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com