I'm having a little problem here. I have the following CSS code:
body
{
margin: 0 0 200px; //Same height of the footer
}
div.content
{
display: table;
margin: 0 auto;
}
div.main-content
{
margin: 20px 10px;
text-align: left;
background-color: rgba(255, 255, 255, 0.95);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
padding: 15px;
-webkit-box-shadow: 0px 4px 5px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 4px 5px 0px rgba(0,0,0,0.75);
box-shadow: 0px 4px 5px 0px rgba(0,0,0,0.75);
}
footer
{
position: absolute;
left: 0;
bottom: 0;
height: 200px;
width: 100%;
overflow: auto;
background-color: rgba(67, 191, 115, 0.95);
}
By this way, in all pages I use:
<div class='content'>
<div class='main-content'>
//Page content goes here
</div>
</div>
<footer>
//Footer content goes here
</footer>
My problem is that the footer is not keeping the width of the page if the resolution is lower than the content, becoming like this:

I've created this fiddle that shows the problem too: http://jsfiddle.net/pmb1vbdh/1/
See how the footer don't expand with the table and lets a white space?
How I can solve this? Thanks!
It works. Check this.
div.content
{
display: table;
margin: 0 auto;
}
div.main-content
{
margin: 20px 10px;
text-align: left;
background-color: rgba(255, 255, 255, 0.95);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
padding: 15px;
-webkit-box-shadow: 0px 4px 5px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 4px 5px 0px rgba(0,0,0,0.75);
box-shadow: 0px 4px 5px 0px rgba(0,0,0,0.75);
}
footer
{
position: absolute;
left: 0;
bottom: 0;
height: 200px;
width: 100%;
overflow: auto;
background-color: rgba(67, 191, 115, 0.95);
}
<div class='content'>
<div class='main-content'>
//Page content goes here
</div>
</div>
<footer>
//Footer content goes here
</footer>
EDIT for comments in others' answer;
demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With