屏幕底部的 Div

Div in the bottom of the screen

本文关键字:Div 底部 屏幕      更新时间:2023-09-26

如何将div放在屏幕底部而不是页面?

但我不想使用position:fixed因为我想一旦向下滚动,div 就会像其他元素一样上升。

喜欢这个网站中的div

您可以使用

vh单位来执行此操作。

body, html {
  height: 1000px;
  margin: 0;
}
div {
  position: relative;
  width: 100px;
  height: 100px;
  background: tan;
  top: calc(100vh - 100px);
}
<div></div>

尝试将此 css 添加到您的 id 或类中:

div {   
position: absolute; 
bottom: 0; 
}