0

I want to position a div at the bottom of the document, but it is only going to the bottom of the viewport. How can I do this with CSS only? I tried position: absolute; bottom: 0; but that only puts it at the bottom of the viewport. Thanks for any help.

stonefish
  • 21
  • 2
  • You don't have to position it for it to be at the end of the document. Just put the div at the end of the document in the markup. – ray Feb 02 '22 at 23:10

1 Answers1

-1

Use position: relative; on the parent container where you're gonna use the position: absolute;. See the snippet below:

.wrapper {
  height: 150vh;
  position: relative;
}

footer {
  position: absolute;
  bottom: 0;
  right: 0;
  left: 0;
  background: blue;
}
<div class="wrapper">
  <footer>Footer</footer>
</div>

More on positions here.

Yong
  • 1,622
  • 1
  • 4
  • 29