It is not a good thing to put a fixed width on body. If you can't change that, then I think you can put position:relative
on the <html>
, and put
position:absolute
left:0
right:0
bottom:0
on the footer. But this approach depends on there is no relative positioned elements between <html>
and your <footer>
In general, if you want a child element's width to exceed its parent's, you can use several ways:
1) negative margin: this would require you know exactly how much pixels the child's width would be exceeding
2) absolute/relative postioning: this is more suitable for your situation because you want the child's width be relative to the screen(the body's width is irrelevant in your case). So you just have to set the element with the screen's width (in your case <html>
) to be relative postioned and the desired child to be absolutely positioned.