HTML CSS examples for CSS Layout:Flex
Block elements only inside flexbox
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style id="compiled-css" type="text/css"> .fill-height-or-more { min-height:100%; display:flex; flex-direction:column; } .fill-height-or-more>div { flex:2;<!--from w w w .j av a2 s . co m--> justify-content:center; } .some-area>div { padding:2rem; } .some-area>div:nth-child(1) { background:Chartreuse; } .some-area>div:nth-child(2) { background:yellow; } .some-area>div:nth-child(3) { background:blue; } .some-area>div:nth-child(4) { background:pink; } .some-area>div:nth-child(5) { background:WhiteSmoke; } .some-area>div h1, .some-area>div h2 { margin:0 0 0.3rem 0; border:2px solid OrangeRed; } .some-area>div p { margin:0; display:block; width:41%; float:left !important; border:2px solid grey; } html, body { height:100%; } </style> </head> <body> <section class="some-area fill-height-or-more"> <div> <h1>Boxes That Fill Height (or more)</h1> <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p> <p>lorem ipsum</p> </div> <div> <h2>Two</h2> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Error ut.</p> </div> </section> </body> </html>