February 2017
Intermediate to advanced
152 pages
3h 53m
English
You now have a complete understanding of the CSS Flexible Box Layout Module Level 1 specification. Now that you’ve been introduced to all of the flex layout properties, it’s time to put this newfound knowledge into practice by implementing a few flex solutions.
We covered a typical layout in Chapter 3. Let’s take a look at a similar example. In this scenario we will have the navigation appear between the header and main content on wide screens, with the navigation below the content in both the markup and on narrow screens (see Figure 4-1):
<body><header><h1>Document Heading</h1></header><main><article><h2>This is the heading of the main section</h2><p>This is a paragraph of text.</p></article><aside>Here is the aside</aside></main><nav><ahref="/">Home</a><ahref="/about">About</a><ahref="/blog">Blog</a><ahref="/jobs">Careers</a><ahref="/contact">Contact Us</a></nav><footer><p>Copyright©2017<ahref="/">My Site</a></p></footer></body>
We lay the site out for smaller devices, then alter the appearance for larger screens. In just a few lines of CSS, we can make this layout completely responsive:
html{background-color:#deded8;font-family:trebuchet,geneva,sans-serif;}body{margin:0;}article,aside,footer,header{padding:0.5rem;box-sizing:border-box;}header{background-color:#333;color:#ccc;text-align:center;border-bottom:1pxsolid;}aside{background-color:white ...
Read now
Unlock full access