Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to make div fixed in the bottom

i want to make div "menu" in the bottom fixed even if scrolling is there any way i could do it please any help

.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>

i want to make div "menu" in the bottom fixed even if scrolling is there any way i could do it please any help

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Replace position: relative to position: fixed on menu, and style it take position in the bottom with left: 0 and bottom: 0:

.overflow {
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.2);
  position: absolute;
  inset: 0px;
  display: block;
  min-height: 2000px;
}
.menu {
  /* 👇 Add these */
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  margin-top: auto;
  background-color: white;
  border-radius: 12px 12px 0px 0px;
  max-height: 90%;
  transform: translateY(0px);
  transition: transform 250ms ease-out 0s;
}
<div class="overflow">
</div>
<div class='menu'>
  <h1>item 1 </h1>
  <h1>item 1 </h1>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading