我有一个链接,我希望它总是在页面的底部。我尝试了显示:Flex和显示项目:Flex-End,但问题是div不会到页面的底部。我可以只做margin-top:375 px,但我希望它是在手机和电脑的底部有人可以帮助吗?
lnxxn5zx1#
这就是你要找的就像其他人说的,bottom: 0和position: fixed是你需要的。width: 100%将在页面上拉伸div。当你添加fixed到一个元素时,它就变得独立于所有其他元素,这使得定位变得很棘手。我添加了left: 50%;和transform: translate (-50%, 0);,它有助于将元素置于页面中心。Source:(Center aligning a fixed position div)
bottom: 0
position: fixed
width: 100%
div
fixed
left: 50%;
transform: translate (-50%, 0);
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; }
个字符
mmvthczy2#
我会尝试将此添加到您希望粘在底部的元素中。
position: fixed; bottom: 0;
字符串
2条答案
按热度按时间lnxxn5zx1#
这就是你要找的
就像其他人说的,
bottom: 0
和position: fixed
是你需要的。width: 100%
将在页面上拉伸div
。当你添加
fixed
到一个元素时,它就变得独立于所有其他元素,这使得定位变得很棘手。我添加了left: 50%;
和transform: translate (-50%, 0);
,它有助于将元素置于页面中心。Source:(Center aligning a fixed position div)
个字符
mmvthczy2#
我会尝试将此添加到您希望粘在底部的元素中。
字符串