Force sidebar height 100% using CSS (with a sticky bottom image)?
UPDATE: As this answer is still getting votes both up and down, and is at the time of writing eight years old: There are probably better techniques out there now. Original answer follows below.
Clearly you are looking for the Faux columns technique :-)
By how the height-property is calculated, you can't set height: 100%
inside something that has auto-height.
Make sidebar height 100% of the browser window
Percentage heights are relative, you want the containing element .container
to stretch the full height of the viewport, so it needs a height of 100%, but 100% of what? So you also need to set it on your html
and body
elements. Then simply give your absolutely positioned sidebar bottom:0;
to stretch it the full height.
Simply change your CSS thus:
html, body { /* ensure the available document space is the full height of the viewport */
height:100%;
padding:0;
margin:0;
}
.container {
overflow: hidden;
position: relative;
height:100%; /* <-- make the containing element full height */
}
.leftwrapper {
background-color: #0b7582;
bottom: 0;
float: left;
position: absolute;
text-align: center;
top: 0;
width: 8%;
bottom:0; /* <-- anchor the element to both the top and the bottom of the viewport */
}
.rightwrapper {
float: left;
margin-left: 8%;
width: 92%;
}
CSS - Flex Sidebar - full height of the page - Weebly
I have edited some of your CSS code below here, first I am rewriting position absolute to fixed and min-height to the height and then add overflow scroll property, I hope your problem solved.
@media screen and (min-width: 64.0625em){
body.nav-position-sidebar .header {
position: fixed;
top: 0;
left: 0;
width: 260px;
height: 100vh;
padding: 40px;
border-bottom: none;
/* display: flex; */
/* flex-direction: row; */
overflow: auto;
}
}
Related Topics
Two Divs, One Fixed Width, the Other, the Rest
CSS Flexbox: Difference Between Align-Items and Align-Content
What Is Caret Symbol ^ Used for in CSS When Selecting Elements
Where Do the Lost Pixels Go in a Percent CSS Layout
How to Find Out When I Can Safely Drop Vendor Prefixes for a CSS3 Property
Why Do All Browsers Download All CSS Files - Even for Media Types They Don't Support
How to Use Chrome Web Inspector to View Hover Code
Immediate Child Selector in Less
Webkit CSS to Control the Box Around the Color in an Input[Type=Color]
How to Define a Class Name on Paragraph Using Markdown
Media Queries and Background Images
Why Doesn't Position: Sticky Work in Chrome
Styling Browser-Native Video Controls
Disable CSS Animation on Pseudo Element Inherited from Parent