Ask Your Question
1

What is the method for positioning the body div at the bottom of the page?

asked 2022-05-30 11:00:00 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-09-09 23:00:00 +0000

nofretete gravatar image

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.

edit flag offensive delete link more

Your Answer

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

Add Answer


Question Tools

Stats

Asked: 2022-05-30 11:00:00 +0000

Seen: 12 times

Last updated: Sep 09 '22