css - handsontable 的初始宽度没有很好地设置在 flexbox 中

标签 css scroll flexbox width handsontable

我有一个放在 flex box 中的手控器。

https://jsbin.com/rikufelosi/1/edit?html,output

行为很奇怪:至少在 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>

最佳答案

.ht_clone_left .wtHolder 中有 css overflow-y:auto。因此,只需在 css 中添加以下代码即可将其删除。它会解决你的问题希望如此..

  .wtHolder {
width: 100% !important;
   }

.ht_clone_left .wtHolder {
  overflow:hidden;
  }

已添加 this jsbin给你..请看..

关于css - handsontable 的初始宽度没有很好地设置在 flexbox 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46969415/

相关文章:

html - 为较新版本的 chrome 创建带有两行文本的输入类型 ="button"

jquery - 在 Wordpress 中自动将用户上传的内容转换为灰度

iphone - UITableView 节标题 1px 光泽/阴影重叠

c# - 如何使用鼠标滚轮滚动面板?

html - 聊天网络应用 : flex-boxes inside div position:fixed

html - 文本不适合方框。 CSS 问题

qt - 在Qt中滚动事件检测

html - 在表头 <th> 元素上使用 flexbox

html - 在 flexbox 中保持包含图像的 div 的纵横比

html - 向左浮动导致 div 获得 'margin'