I am the furthest from a designer and as such look to others for visual design. I have made purchase of a template where the designer used a min-height: 1000px
attribute on the main container to ensure that the background colour always stretched to the bottom.
I am trying to correct this and as such came across the following question; Make a div fill the height of the remaining screen space - Which clearly identifies the use of the new(ish) css3 flex attributes. However it appears as though perhaps my current structure won't allow for its correct use? or am I approaching it incorrectly?
CSS:
body {
width: 100%;
margin: 0;
padding: 0;
font-family: 'Open Sans',Helvetica, Arial, sans-serif;
color: #666666;
-webkit-font-smoothing: antialiased;
/* Fix for webkit rendering */
-webkit-text-size-adjust: 100%;
font-size-adjust: 100%;
font-weight: 400;
font-size: 13px;
line-height: 1.475;
background-color: #FFF; }
#main {
display: -webkit-flex;
display: flex;
flex-direction: column;
width: 100%;
position: relative;
background: #e8e8e8; }
#content_wrapper {
position: relative;
display: block;
-webkit-flex: 1;
flex: 1;
left: 0px;
margin-left: 230px; }
HTML Structure:
<body>
<header>
<!-- Header Content Here - This is sticky -->
</header>
<div id="main">
<aside id="sidebar_left" class="affix"><!-- Sidebar Content Here - This is sticky --></aside>
<section id="content_wrapper"><!-- Webpage Content Here - This can scroll when necessary. --></section>
</div>
</body>
On pages with appropriate amounts of content, there is nothing wrong with what is seen above. It works the same as the authors original min-height: 1000px
solution did, however on short content pages (such as 404 Error etc) the content fills approx 1/3 - 1/2 of the page before stopping.
- I do not have a footer, nor do I plan on implimenting one. (In case it gets asked later)
- I have tried to use
height: 100%
on the html and body tags to no avail - I previously attempted to use
height:100vh
but realized that it would also add height for my header region as it exists within the viewport itself.
How should I be approaching this issue? Is Flex the appropriate resolution here?