gpt4 book ai didi

javascript - 使用第 3 方插件时包裹 child

转载 作者:行者123 更新时间:2023-11-30 16:59:36 24 4
gpt4 key购买 nike

我正在使用 highcharts 插件创建图表。

我的问题是我想以相对方式设置高度和宽度。

我尝试包装它并将宽度设置为相对宽度,但高度仍然使用 child 的高度而不是父(包装)。

<div style="width:60vw; height:40vh">
<div id="overallAlerts"></div>
</div>

JS:

window.chart = new Highcharts.StockChart({
chart: {
renderTo: 'overallAlerts'
},
.....

截图: enter image description here

最佳答案

问题很可能是您没有在子元素上定义任何高度,从而迫使图表恢复为默认值。

Highstock documentation状态:

height : Number

An explicit height for the chart. By default the height is calculated from the offset height of the containing element, or 400 pixels if the containing element's height is 0.

只需添加 100%heightwidth:

#overallAlerts {
height: 100%;
width: 100%;
}

或者,如果你真的坚持使用内联样式:

<div id="overallAlerts" style="height: 100%; width: 100%;"></div>

关于javascript - 使用第 3 方插件时包裹 child ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29118926/

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