我有一个装在弹性盒子里的手动桌子。
https://jsbin.com/rikufelosi/1/edit?html,输出
行为非常奇怪:至少在Mac下的Chrome或Safari中,加载页面后,handsontable的宽度不正确。如果我们向右滚动它,我们会看到宽度正确延伸。
有谁知道发生了什么事吗?以及如何修复它?
<!DOCTYPE html>
<html>
<head>
<script src="https://handsontable.github.io/ngHandsontable/node_modules/angular/angular.js"></script>
<script src="https://docs.handsontable.com/pro/1.8.2/bower_components/handsontable-pro/dist/handsontable.full.js"></script>
<link type="text/css" rel="stylesheet" href="https://docs.handsontable.com/pro/1.8.2/bower_components/handsontable-pro/dist/handsontable.full.min.css">
<script src="https://handsontable.github.io/ngHandsontable/dist/ngHandsontable.js"></script>
<style>
.rb {
display: flex;
flex-direction: column;
height: 100%;
}
.rb .container {
flex: 1;
display: flex;
padding: 0;
width: 100%;
height: 100%
}
</style>
</head>
<body ng-app="app" ng-controller="Ctrl">
<div class="rb">
<div class="container">
<div style="flex:1; overflow:hidden; height: 100px">
<hot-table settings="settings" on-after-create-row="onAfterCreateRow" datarows="sheetHot"></hot-table>
</div>
<textarea ng-if='(selectedItem !== "userpanel") && (selectedItem !== "panel")' ng-model="text" style="flex:1"></textarea>
<div ng-show='selectedItem === "userpanel"' style="flex: 1"></div>
<div ng-show='selectedItem === "panel"' style="flex: 1"></div>
</div>
</div>
<script>
var app = angular.module('app', ['ngHandsontable']);
app.controller('Ctrl', ['$scope', '$filter', '$timeout', 'hotRegisterer', function ($scope, $filter, $timeout, hotRegisterer) {
$scope.sheetHot = [[5, 6, 7, 8, 9, 19, 11, 12], [5, 6, 7, 8, 9, 19, 11, 12], [5, 6, 7, 8, 9, 19, 11, 12], [5, 6, 7, 8, 9, 19, 11, 12], [5, 6, 7, 8, 9, 19, 11, 12], [5, 6, 7, 8, 9, 19, 11, 12]];
$scope.settings = {
rowHeaders: true,
colHeaders: true,
contextMenu: true,
onAfterCreateRow: function(index, amount) {
console.log("onAfterCreateRow");
$timeout(function() {
$scope.$digest();
});
}
};
}]);
</script>
</body>
</html>
overflow-y:auto
中有css.ht_clone_left .wtHolder
。因此只需在 css 中添加以下代码即可将其删除。它会解决你的问题希望如此..
.wtHolder {
width: 100% !important;
}
.ht_clone_left .wtHolder {
overflow:hidden;
}
为您添加了这个jsbin..请看一下..
删除
overrflow:hidden
中的
<div style="flex:1; height: 100px">
<div class="container">
<div style="flex:1; height: 100px">
<hot-table settings="settings" on-after-create-row="onAfterCreateRow" datarows="sheetHot"></hot-table>
</div>
<textarea ng-if='(selectedItem !== "userpanel") && (selectedItem !== "panel")' ng-model="text" style="flex:1"></textarea>
<div ng-show='selectedItem === "userpanel"' style="flex: 1"></div>
<div ng-show='selectedItem === "panel"' style="flex: 1"></div>
</div>
为什么不使用
!important
覆盖 CSS 中的 Handsontable 样式?喜欢:
.wtHolder {
width: 100% !important;
}
看看这个JSBin。
希望这有帮助!