I have a nav bar and 4 graphs on my page as shown in the below image.
My goal is to fit all 4 graphs on the page without displaying scroll in various screen heights. My code looks like below:
<div className="container">
<div className="graph">
<Chart /> //graph 1
<Chart /> //graph 2
</div>
<div className="graph">
<Chart /> //graph 1
<Chart /> //graph 2
</div>
</div>
I tried putting 90vh to the container and fix heights to the <Chart />
components.
2
Answers
Is this what you are looking for?
As I get your question, you need a way to change the ratio based on a given height.
The known way to change the ratio based on a given width (for example => 50%) is to set padding-bottom or padding-top in percentage
The other way for changing the ratio based on a given height (% or vh) is a bit tricky using something extra other than css which is an image with the wanted ratio to hold the parent-container then the changing-ratio component(child) would be positioned absolute above the parent-container with width and height 100%, to change with the parent, see the below snippet =>