One method to position the body div at the bottom of the page is to use CSS. Here's an example:
HTML:
<body>
<div class="content">
<!-- page content here -->
</div>
<div class="footer">
<!-- footer content here -->
</div>
</body>
CSS:
html, body {
height: 100%;
margin: 0;
}
.content {
min-height: 100%;
margin-bottom: -50px; /* height of the footer */
}
.footer {
height: 50px;
}
This method sets the height of the HTML and body elements to 100% and removes any margins. The content div has a min-height of 100% to stretch to the bottom of the page, then the margin-bottom is set to the height of the footer to push it off screen. Finally, the footer div has a fixed height.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-05-30 11:00:00 +0000
Seen: 12 times
Last updated: Sep 09 '22