I have to create 3 buttons inside the div container. The space below the buttons must always be double the space above the buttons. How can we write CSS to achieve this? I have attached to image for a clear understanding.
(Here 1H signifies ratio meaning if the space above is 1H then the space below will be 2H)
<div class="main">
<div class="upper-div></div>
<div class="lower-div">
<button class="btn-1">1</button>
<button class="btn-2">1</button>
<button class="btn-3">1</button>
</div>
</div>
I want to know the CSS to create such design using HTML and CSS only.
2
Answers
One way is to use a grid system. In this example, I made a grid with 3 rows, with the size of 1 fr (1H in your diagram), 36px and 2 fr (2H in your diagram). After that, I created a div to house the buttons, and inserted this div into the second row of the grid.
I think you could probably achieve this with CSS grid: