Most of most solutions are based on creating a fixed footer position: fixed
.
Other alternatives given is an absolute position.
Example
.footer {
position: absolute;
bottom: 0;
width: 100%;
height: 60px;
background-color: #f5f5f5;
}
But a floating footer is not to our liking, it is not a solution worse when we have a floating menu and a footer with a
height
too high end.
But what is the point of having a footer that stays at the bottom.
- That it remains only at the bottom when the content or information area does not group in quantity.
Example (area with short content).
A solution to get a footer from this frame:
Now to show a footer only when the content area has very little information.
One solution would be to have jQuery detect the height and apply a class to firmly fit the footer to the bottom.
How would a solution be planted with jQuery ( for lovers of jquery programming ).
Or what other alternatives can be applied with css without the footer being floating?
For this you don't need JavaScript/jQuery or HTML5/CSS3, there is a CSS solution that works even with older versions of browsers. The idea is the following:
height:100%
for thehtml
andbody
.padding
bottom equal to or greater than the height of the footerThe code would look like this:
Since you want an alternative with JavaScript/jQuery, here's one for you; although I tell you that there can be many possibilities and, as I mentioned in a comment, it really is not necessary with the CSS described above.
The idea would be to do something like this:
Here is an example of how it could be done:
You can do it via flexbox:
Try taking two out
p
so you can see the behavior.