How to make two charts using highchart show up in the same line side by side using div

怎甘沉沦 提交于 2020-01-21 20:04:15

问题


I want to display two charts in the same line using div. Can you please help?

Here is the what I am trying but it shows up in 2 lines.

<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
    <div>
        <div id="container" style="width: 200px; height: 200px; diplay:inline"></div>
        <div id="container2" style="width: 200px; height: 200px; display:inline"></div>

    </div>

full code in http://jsfiddle.net/nCe36/


回答1:


Just float the containers left!

Either give both #container and #container2 a left float:

#container,
#container2 {
    float: left;
}

(Demo)

Or give both containers a class (say, "container") and float that class left:

.container {
    float: left;
}

(Demo)

Edit: display: inline-block will also work, as @Nile has pointed out. It's a matter of personal preference: I tend to prefer floats; some people, inline-blocks. For more information on which to use, you might want to check out this post: float:left; vs display:inline; vs display:inline-block; vs display:table-cell;.




回答2:


Try:

display: inline-block;

Modified example: http://jsfiddle.net/pzqLG/



来源:https://stackoverflow.com/questions/16755121/how-to-make-two-charts-using-highchart-show-up-in-the-same-line-side-by-side-usi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!