在html/css中将div拉伸到整个页面

tgabmvqs  于 5个月前  发布在  其他
关注(0)|答案(2)|浏览(50)

我有一个链接,我希望它总是在页面的底部。我尝试了显示:Flex和显示项目:Flex-End,但问题是div不会到页面的底部。我可以只做margin-top:375 px,但我希望它是在手机和电脑的底部有人可以帮助吗?

lnxxn5zx

lnxxn5zx1#

这就是你要找的
就像其他人说的,bottom: 0position: fixed是你需要的。
width: 100%将在页面上拉伸div
当你添加fixed到一个元素时,它就变得独立于所有其他元素,这使得定位变得很棘手。我添加了left: 50%;transform: translate (-50%, 0);,它有助于将元素置于页面中心。
Source:(Center aligning a fixed position div

div.bottom-nav {
  background-color: #232323;
  width: 100%;
  height: 55px;
  line-height: 55px;
  text-align: center;
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 0);
}
a {
  color: white;
}

个字符

mmvthczy

mmvthczy2#

我会尝试将此添加到您希望粘在底部的元素中。

position: fixed;
bottom: 0;

字符串

相关问题