stick content at the bottom of the page

530 views Asked by At

My problem:

I designed single page. Header, content(section and aside) and footer.

Footer and header are sticky.

I want content to stick to the end of page and above footer.

Guide me, please.

1

There are 1 answers

1
ab29007 On BEST ANSWER

Are you implying something like this. In this example. no matter what screen size your content will always stick to the footer, even if there is a single line in it.

*{
  box-sizing: border-box;
}
body, html{
  height: 100%;
  width: 100%;
  margin: 0;
}
body{
  display:flex;
  flex-direction: column;
}
#container
{
    margin: 0 auto;
    width:90%;
    background-color: white;
    border: 2px solid black;
    flex-shrink:0;
    flex-grow:1;
    display:flex;
}
.header,.footer
{
    margin: 0 auto;
    width:100%;
    text-align: center;
    height:1.5em;
    background-color: white;
    border: 1px solid black;
    flex-shrink:0;
    background-color:green;
  color:white;
}
.col {
    height:90%;
    flex-shrink:0;
    flex-grow:1;
    margin:0 2% 0 2%;
}
<div class="header">
  Header here
</div>
<div id="container">
  <div class="col">
    test column 1
    <p>
    Content
    </p>
    <p>
    Content
    </p>
    <p>
    Content
    </p>
  </div>
  <div class="col">
    test column 2
    <p>
    Content
    </p>
    <p>
    Content
    </p>
    <p>
    Content
    </p>
  </div>
</div>
<div class="footer">
Footer Here
</div>