<div id="page">
...
<section class="sidebar-top">
...
</section>
<section class="content">
...
</section>
<section class="sidebar-bottom">
...
</section>
...
</div>
Essentially we just set up a typical three column template. Now apply some CSS
section.sidebar-top,
section.sidebar-bottom {
float: left;
}
section.content {
float: right;
}
A responsive sidebar utilizes breakpoints to give you greater control over your design. This causes the section.sidebar-bottom to float underneath section.sidebar-top and keep the content area to the right of the sidebar. In this case we just set up a left sidebar that has a breakpoint we can utilize in responsive design.
For my website I set a breakpoint for tablets - keep the top of the sidebar aligned left to the content, but stack the second half of the sidebar below the content.
@media (max-width: 979px) and (min-width: 768px) {
section.sidebar-bottom {
clear: both;
float: none;
width: 100%;
}
}
And when we hit mobile, the sections stack on top of each other as they would in normal element hierarchy.
@media (max-width: 480px) {
section.sidebar-top,
section.content,
section.sidebar-bottom {
clear: both;
float: none;
width: 100%;
}
}
Want more? Sign up for my weekly newsletter