Gerard Santos Gerard Santos - 3 months ago 14
HTML Question

Sticky Footer not fully stick on the bottom

I'm trying to add a sticky footer on my two-column content but the problem is it can't really fully occupy the bottom part of the page.

I've been applying css sticky footer I found in the web but I can't make it to work.

I've attached my code below.

Codepen code here: I've add my code into Codepen Here



<style> body {
margin: 0;
padding: 0;
/*background-image: url("main-bg.jpg");*/
background-color:green;
height: 100%;
}
.container {
width: 100%;
position: relative;
margin-bottom: -50px;
height: 100%;
}
/* HEADER SECTION */

.header {
background-color:blue;
/*background-image: url("bgs.jpg");
background-repeat: repeat;
background-size: cover;
*/
height: 100px;
overflow: auto;
}
.header ul {
list-style-type: none;
margin: 0;
padding: 0;
}
.header ul li {
float: right;
padding: 14px 16px;
}
.header li ul {
display: none;
}
.header a {
text-decoration: none;
color: white;
font-size: 20px;
}
.header li:hover ul {
display: block;
}
/*FOOTER SECTION*/

.footer {
clear: both;
padding: 5px 5px;
background: #cc9;
height: 50px;
}
.footer-right {
float: right;
}
.footer-left {
float: left;
}
/*CONTENT SECTION*/

.content {
padding: 10px;
padding-bottom: 50px;
height: 100%;
overflow: hidden;
background-color:silver;
width: 95%;
}
.left-content {
float: left;
width: 800px;
padding: 10px;
margin-left: 150px;
margin-right: 20px;
margin-top: 20px;
margin-bottom: : 150px;
/*background-image:url("main-content-bg.png");*/
background-color: white;
-webkit-box-shadow: 8px -9px 20px 9px rgba(112, 112, 138, 0.69);
-moz-box-shadow: 8px -9px 20px 9px rgba(112, 112, 138, 0.69);
box-shadow: 8px -9px 20px 9px rgba(112, 112, 138, 0.69);
}
.right-content {
float: right;
width: 320px;
padding: 10px;
background: #99c;
}
#footer {
clear: both;
padding: 5px 5px;
background: #cc9;
height: 40px;
}
</style>

<body>

<div class="container">

<div class="header">
<br>
<ul>
<li><a href="#">HOME</a>
</li>
<li><a href="#">SERVICES</a>
</li>
<li><a href="#">PORTFOLIO</a>
<ul>
<li><a href="#">Birthday Events</a>
</li>
<li><a href="#">Wedding Events</a>
</li>
<li><a href="#">Anniversary Events</a>
</li>
<li><a href="#">Other Events</a>
</li>
</ul>
</li>
<li><a href="#">CONTACT</a>
</li>
<li><a href="#">ABOUT</a>
</li>
</ul>
</div>

<div class="content">
<div class="left-content">
<p>All About Pixel Foto</p>
<p>Nunc tincidunt, elit non cursus euismod, lacus augue ornare metus, egestas imperdiet nulla nisl quis mauris. Suspendisse a pharetra urna. Morbi dui lectus, pharetra nec elementum eget, vulputate ut nisi. Aliquam accumsan, nulla sed feugiat vehicula,
lacus justo semper libero, quis porttitor turpis odio sit amet ligula. Duis dapibus fermentum orci, nec malesuada libero vehicula ut. Integer sodales, urna eget interdum eleifend, nulla nibh laoreet nisl, quis dignissim mauris dolor eget mi.
Donec at mauris enim. Duis nisi tellus, adipiscing a convallis quis, tristique vitae risus. Nullam molestie gravida lobortis. Proin ut nibh quis felis auctor ornare. Cras ultricies, nibh at mollis faucibus, justo eros porttitor mi, quis auctor
lectus arcu sit amet nunc. Vivamus gravida vehicula arcu, vitae vulputate augue lacinia faucibus. Donec volutpat nibh sit amet libero ornare non laoreet arcu luctus. Donec id arcu quis mauris euismod placerat sit amet ut metus. Sed imperdiet
fringilla sem eget euismod. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Pellentesque adipiscing, neque ut pulvinar tincidunt, est sem euismod odio, eu ullamcorper turpis nisl sit amet velit.
Nullam vitae nibh odio, non scelerisque nibh. Vestibulum ut est augue, in varius purus. Quisque ligulas ipsum, euismod atras vulputate iltricies etri elit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
Nulla nunc dui, tristique in semper vel, congue sed ligula. Nam dolor ligula, faucibus id sodales in, auctor fringilla libero. Pellentesque pellentesque tempor tellus eget hendrerit. Morbi id aliquam ligula. Aliquam id dui sem. Proin rhoncus
consequat nisl, eu ornare mauris tincidunt vitae. Vestibulum sodales ante a purus volutpat euismod. Proin sodales quam nec ante sollicitudin lacinia. Ut egestas bibendum tempor. Morbi non nibh sit amet ligula blandit ullamcorper in nec risus.
Pellentesque fringilla diam faucibus tortor bibendum vulputate. Etiam turpis urna, rhoncus et mattis ut, dapibus eu nunc. Nunc sed aliquet nisi. Nullam ut magna non lacus adipiscing volutpat. Aenean odio mauris, consectetur quis consequat quis,
blandit a nunc. Sed orci erat, placerat ac interdum ut, suscipit eu augue. Nunc vitae mi tortor. Ut vel justo quis lectus elementum ullamcorper volutpat vel libero.</p>
</div>
<div class="right-content">
<p align="center">All About Me</p>
<p>I'm Dick Roman and I foresee what I will become when I first time use a camera. I was eager to have my own camera and take elegant photos of my unforgettable moments in my life. It was served as my inspiration to purse and take this field of photography.
Today I am able to render my services to my clients and I will guarantee every works I made will be best of the best</p>
<ol style="list-style-type:none;align:center">
<p>Today I am rendering my skills as a:</p>
<li>Image Editor</li>
<li>Landscape Photograher</li>
<li>Video Editor</li>
<li>Web Designer</li>
</ol>

<p align="center">You could drop-by to my social media profiles</p>
<p align="center">Just click on any links below to visit my account</p>

<ul style="list-style-type:none">
<li>
<a href="#">Facebook</a>
</li>
<li><a href="#">Twitter</a>
</li>
<li><a href="#">Instagram</a>
</li>
</ul>
</div>
</div>

<div class="footer">
<div class="footer-left">
<p>&copy;Copyright 2016 - Codeblocks Design</p>
</div>


<div class="footer-right">
<p>
<a href="#">
<img src="fb.png" height="60%">
</a>
<a href="#">
<img src="twitter.png" height="60%">
</a>
<a href="#">
<img src="instagram.png" height="60%">
</a>
<a href="#">
<img src="google.png" height="60%">
</a>
</p>
</div>
</div>

</div>
</body>




How the code above displayed on my browser:
Here's the output

Answer

One easy way is to put your footer's content in a <footer> tag. Then apply position:fixed; to let the footer stick to the bottom.

If there are any margin issues after that, add this to the top of the styling

*{
    margin:0;
}
Comments