HTML CSS examples for CSS Layout:Flex Container
Inner div with square ratio and flexbox
<html lang="en"> <head> <title>[SO] Half the height of its parent, must be a square (dimensions unknown)</title> <style> .flex {<!--from ww w . j a v a 2 s.c o m--> display: table-cell; width: 12rem; height: 20rem; vertical-align: middle; transform: rotate(90deg) translateY(-50%); background-color: lightblue; } .flex.large { height: 35rem; } .item { width: 50%; height: 0; margin-left: 25%; padding-top: 50%; background-color: lightyellow; } </style> </head> <body translate="no"> <div class="flex"> <div class="item"></div> </div> <hr> <div class="flex large"> <div class="item"></div> </div> </body> </html>