I have the following page showing the HTML as well as the CSS. I want the five buttons on the left (div id=button1..5) to always be square at any aspect ratio and resolution of the screen. Also, I want the five buttons to always fill the middle div (id=menu). In fact, I AM ABLE TO DO BOTH, but NOT TOGETHER! The latter is easy with Flex and the former as you can see I have done in the code below. I have looked at several examples on SO, notably this one, but they don't do what I am talking about.
Any suggestions? Note: Preferably no Javascript...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style>
html, body {
margin:0;
padding:0;
}
#container {
display:flex;
flex-direction: column;
background-color: #444;
height:100vh;
width:100%;
margin:0;
padding:0;
}
#top{
background-color: #777;
height:5%;
width:100%;
margin:0;
padding:0;
}
#main{
background-color: #DDD;
height:100%;
width:100%;
margin:0;
padding:0;
align-items: stretch;
}
#menu{
display:flex;
flex-direction: column;
background-color: #FFF;
height:100%;
width:10%;
margin:0;
padding:0;
}
.buttons{
display:inline-block;
position:relative;
height:0;
margin:0;
padding-bottom:100%;
}
#button1{background-color:blue; margin:2px 0 2px 0;}
#button2{background-color:green; margin:2px 0 2px 0;}
#button3{background-color:red; margin:2px 0 2px 0;}
#button4{background-color:black; margin:2px 0 2px 0;}
#button5{background-color:orange; margin:2px 0 2px 0;}
.img-container {
justify-content: center;
display: flex;
flex-direction: row;
overflow: hidden;
padding:16px;
}
.img-container .img-to-fit {
flex: 1;
height: 100%;
}
.fill {
display: flex;
justify-content: center;
align-items: center;
overflow: hidden
}
.fill img {
flex-shrink: 0;
min-width: 100%;
min-height: 100%
}
#bottom {
height:2%;
display:flex;
}
#bottom1{background-color:blue;}
#bottom2{background-color:green;}
#bottom3{background-color:red;}
#bottom4{background-color:white;}
#bottom5{background-color:orange;}
.bottoms{
height:100%;
width:20%;
margin:0;
padding:0;
}
</style>
</head>
<body>
<div id="container">
<div id="top"/>
<div id="main">
<div id="menu">
<div id="button1" class="buttons">
<div class="img-container">
<img class="img-to-fit" src="parcel.png" />
</div>
</div>
<div id="button2" class="buttons"/>
<div id="button3" class="buttons"/>
<div id="button4" class="buttons"/>
<div id="button5" class="buttons"/>
</div>
</div>
<div id="bottom">
<div id="bottom1" class="bottoms"/>
<div id="bottom2" class="bottoms"/>
<div id="bottom3" class="bottoms"/>
<div id="bottom4" class="bottoms"/>
<div id="bottom5" class="bottoms"/>
</div>
</div>
</body>
</html>