Currently I have two divs , One for my chart legend and one for my chart. I want to display the legend at the top. My legend is 50px; But when I use height: calc(100%-50px). It minuses the 50 pixels from the bottom. How do I minus the 50 pixels from the top and put my legend div there instead? I don't mind a solution which uses Javascript or even D3. A pure CSS solution would be nice.
.treemap-chart-container .treemap-chart {
display: inline-block;
width: 100%;
height: calc(100% - 50px);
float: left;
}
.legend {
display: inline-block;
width: 100%;
height: 50px;
overflow-y: scroll;
float: left;
}
<div class="treemap-chart-container">
<div class="treemap-chart"></div>
<div class="legend" id="legendContainer"></div>
</div>
BTW , I realize that the positioning of the div elements affect it as well. If for example , the legend div render 1st,then it will appear at the top. But in my case the chart div is 1st. So how to exchange the positions of the two divs?