I have a problem when try to fix footer at bottom of the page as below picture:
Although I google and see many suggestions, but I'm still facing the problem. I suspect this problem is <div data-reactroot></div>
cannot be set height 100% as its parents. Could anyone help me?
Thanks in advance!
Update: Style of footer:
borderTop: '1px solid #ddd', height: '60px', lineHeight: '60px', backgroundColor: 'white'
The trick is to use a display:table for the whole document and display:table-row with height:0 for the footer. Since the footer is the only body child that has a display as table-row , it is rendered at the bottom of the page.
Just add data-position="fixed" to the div tag if you are using jQuery. Hope this helps.
You need to tell your footer to position itself to the bottom of the surrounding container:
Footer css:
position:absolute; left:0; bottom:0; right:0;
And for the container (the react-root div):
padding-bottom:60px;
As an alternative (if you don't need to support IE 8) you could try this style on the div.container
:
height: calc(100% - 60px);
For any other person the above solutions do not work for, you could try the following steps:
div
a non-static position
such as relative
(remember the default position
is static
)100vh
; this enables it to take up all available space verticallydiv
if not one, give it the following properties; position: absolute; bottom: 0; width: 100%
.UPDATE: In some cases, setting the footer div
position
to absolute
may not work. In such a case, use relative
instead.
Hopefully, the steps above should fix it :-)
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