HTML CSS examples for CSS Layout:Flex Center
Aligning two flex items with one to the top, the other centered
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style id="compiled-css" type="text/css"> html {<!-- www. j av a 2 s. co m--> height:100%; } body { height:100%; margin:0; } #wrap { display:flex; flex-direction:column; height:100%; background-color:Chartreuse; position:relative; } #top { flex:0 0 51px; width:100%; background-color:yellow; } #center { background-color:blue; width:201px; height:301px; position:absolute; left:51%; top:51%; transform:translate(-51%, -51%); } </style> </head> <body> <div id="wrap"> <div id="top"></div> <div id="center"></div> </div> </body> </html>