Skip to content

Instantly share code, notes, and snippets.

@CMCDragonkai
Created September 10, 2013 13:10
Show Gist options
  • Select an option

  • Save CMCDragonkai/6509185 to your computer and use it in GitHub Desktop.

Select an option

Save CMCDragonkai/6509185 to your computer and use it in GitHub Desktop.
CSS: Minimum Fixed Height Sidebar. This sidebar will stretch to the height of the viewport even if the content doesn't push it down, and yet when the content pushes down, the sidebar will also stretch its height with it. Great for sidebars that need to be sticky/affixed and also occupy all of the viewport.
html{
position: relative; //relative is required to contain the absolute sidebar
min-height: 100%; //minimum height make sure that if the content is below 100% of viewport, it will still allow the sidebar to be at 100%, and if the content is greater than 100% of viewport, it will allow stretching
}
.content{
float: left;
width: 70%;
height: 1000px; //example height, you can increase and decrease this height to see it work
}
.sidebar{
position: absolute; //this can be changed to fixed and it will still work
height: 100%;
right: 0;
width: 30%;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment