HTML CSS examples for CSS Layout:Responsive Layout
Responsive CSS grid with pattern
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style id="compiled-css" type="text/css"> .container {<!--from w w w . j a v a 2s . c o m--> max-width:1001px; margin:0 auto; background-color:Chartreuse; } .box { background-color:yellow; width:51%; float:left; height:201px; } .box:nth-child(6n+1) { background-color:blue; height:401px; } .box:nth-child(6n+4) { background-color:pink; height:401px; float:right; } .box { text-align:center; box-sizing:border-box; line-height:201px; font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif; color:OrangeRed; } .box:nth-child(3n+1) { line-height:401px; } .box p { margin:0; } .box:nth-child(3n+2) { background-color:grey; } .box:nth-child(3n+3) { background-color:BlueViolet; } @media screen and (max-width: 620px) { .box { clear:both; width:100%; } } @media screen and (min-width: 621px) { .box { clear:none; width:51%; } } </style> </head> <body> <div class="container"> <div class="box"> <p>Lorem ip</p> </div> <div class="box"> <p>Lore</p> </div> <div class="box"> <p>Lore</p> </div> <div class="box"> <p>Lorem ip</p> </div> <div class="box"> <p>Lore</p> </div> <div class="box"> <p>Lore</p> </div> <div class="box"> <p>Lorem ip</p> </div> <div class="box"> <p>Lore</p> </div> <div class="box"> <p>Lore</p> </div> <div class="box"> <p>Lorem ip</p> </div> <div class="box"> <p>Lore</p> </div> <div class="box"> <p>Lore</p> </div> </div> </body> </html>