javascript - 为什么 div 不采用全宽或 100% 宽度?

标签 javascript angularjs angularjs-directive angularjs-scope

我正在尝试制作表格和图表。当我将两者一起显示时,两者都将采用 100% 宽度。请全屏查看。但是当我应用 ng-show 条件时,图表没有以 100% 宽度显示,为什么?它仅显示宽度的 50% 到 60%。

  • 请全屏检查并点击显示图表按钮..然后它将仅显示 50% 宽度..它应该为 100%..

这是我的代码 http://plnkr.co/edit/lXM2UbYUeT8NSkDeYCgb?p=preview

$scope.isshowTable = true;
$scope.showChart = function() {
    $scope.isshowTable = false;
}
$scope.showTable = function() {
    $scope.isshowTable = true;
}

最佳答案

只需更改图表指令样式 width="100%",图表将默认使用宽度。

http://plnkr.co/edit/HkAD1eyD1QGHIUyU7uml?p=preview

<chart value="basicAreaChart" type="area" height="400" style="width:100%"></chart>

原因如下,http://api.highcharts.com/highcharts#chart.width

width: Number An explicit width for the chart. By default the width is calculated from the offset width of the containing element. Try it:

800px wide

关于javascript - 为什么 div 不采用全宽或 100% 宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34427790/

相关文章:

javascript - Angular ng-repeat - 如何连接或组合来自不同数组的数据

javascript - ng-click inside templateUrl 指令不起作用

javascript - 对象参数的高效内存

javascript - 为什么我得到 undefined 不是函数,ReactJs

javascript - 在 AngularJS 中使用 Bootstrap 模式时,事件冒泡似乎不起作用

AngularJS 范围和延迟

javascript - 在指令中使用 Controller 属性/方法

javascript - 拆分 knockoutjs

javascript - 捕获用户输入并用作 Flickr API 的搜索,需要让按钮点击正常工作

angularjs - 使用 typings 安装 es6-promise