- 此问题在此处已有答案**:
How to keep footer at bottom of screen [duplicate](6个答案)
昨天关门了。
我想使div "菜单"在底部固定,即使滚动有什么办法,我可以做到这一点,请任何帮助
.overflow{
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.2);
position: absolute;
inset: 0px;
display: block;
}
.menu{
display: flex;
flex-direction: column;
position: relative;
margin-top: auto;
background-color: white;
border-radius: 12px 12px 0px 0px;
max-height: 90%;
transform: translateY(0px);
transition: transform 250ms ease-out 0s;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div class="overflow">
</div>
<div class='menu'>
<h1>item 1 </h1>
<h1>item 1 </h1>
</div>
</body>
</html>
我想使div "菜单"在底部固定,即使滚动有什么办法,我可以做到这一点,请任何帮助
1条答案
按热度按时间nhhxz33t1#
将
menu
上的position: relative
替换为position: fixed
,并将其设置为位于底部的left: 0
和bottom: 0
: