Using grid-column-start with auto-placement of grid items - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Column Layout

Description

Using grid-column-start with auto-placement of grid items

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">

body {<!--from  w ww .  j a v a2s.c  o  m-->
   height: 100vh;
   margin: 0;
   display: grid;
   grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
   border: 2px solid black;
}
footer {
   grid-column: 2 / 3;
}
body > * { min-width: 0; }
header { background: tomato; border: 2px solid red;  }
main   { background: yellow; border: 2px solid gold; }
nav    { background: red; border: 2px solid green; }
footer { background: blue;  border: 2px solid blue; }


      </style> 
 </head> 
 <body> 
  <header>
    Header 
  </header> 
  <nav>
    Nav 
  </nav> 
  <main>
    Main 
  </main> 
  <footer>
    Footer 
  </footer>  
 </body>
</html>

Related Tutorials