I have a parent <div> of unknown size and I would like to create a child <div> of the size of the biggest square which can be contained in the parent and center this square in the middle of the parent. Is it possible with HTML and CSS?
I am aware of max-width and max-height but do not know how to ensure the aspect-ratio.
I want to be able to do something like this:
.frame {
  height: 80%;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}
.square {
  width: 750px;
  height: 750px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}
.back {
  width: 100%;
}
.front {
  width: 70.5%;
  top: 23.965%;
  position: absolute;
}<div class="frame">
  <div class="square">
    <img class="back" src="back.png">
    <img class="front" src="front.png">
  </div>
</div>But in the square I want the width and height set based on its parent frame as described. The parent frame can be both landscape or portrait.
 
     
    