1

The footer isn't displaying right at the bottom of the page. How can I fix this?

  /* FOOTER */
  #footer {
    position: relative;
    bottom: 0;
    background-color: black;
    color: white;
    width: 100%;
    height: 5.5rem;        
    margin-left: -8px;
    padding-right: 16px;
    bottom: -8px;
   }
  <footer id="footer">
                  
             </footer>    
SK1dev
  • 1,049
  • 1
  • 20
  • 52

2 Answers2

3

You could change the position to absolute.

position: absolute;

  /* FOOTER */
  #footer {
    position: absolute;
    bottom: 0;
    background-color: black;
    color: white;
    width: 100%;
    height: 5.5rem;        
    margin-left: -8px;
    padding-right: 16px;
    bottom: -8px;
   }

   .footer-text {
     padding-left: 20px;
     padding-top: 10px;
   }
  <footer id="footer">
                  
  </footer>    
Zachary McGee
  • 504
  • 1
  • 4
  • 16
0

It is necessary to use position: absolute.

position: relative just displays an element relative to its normal position. If you put bottom: 10px for example, it will move the element up by 10px. Using bottom: 0px on a relatively positioned element has no effect.

/* FOOTER */

#footer {
  position: absolute;
  bottom: 0;
  background-color: black;
  color: white;
  width: 100%;
  height: 5.5rem;
  margin-left: -8px;
  padding-right: 16px;
  bottom: -8px;
}

.footer-text {
  padding-left: 20px;
  padding-top: 10px;
}
<footer id="footer">

</footer>
Run_Script
  • 2,487
  • 2
  • 15
  • 30