I'm currently working on a website where I want to attach a menu-bar to the bottom of the header using
#menu {
position: absolute;
bottom: 0;
}
Unfortunately, instead of sticking to the bottom of the parent div
, the menu-bar is stuck to the bottom of the screen.
* {
font-family: Arial, sans-serif;
border: 0 solid black;
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
height: 500px; /*for testing*/
background-color: #00FF00;
}
#header {
height: 270px;
border: 1px solid #FF0000;
}
#menu {
display: block;
height: 50px;
padding: 16px;
font-size: 18px;
position: absolute;
bottom: 0;
border: 1px solid #0000FF;
}
<!DOCTYPE html>
<html lang="nl">
<head>
</head>
<body>
<div id="header">
<div id="menu">
<a href="/" id="home">Home</a>
<a href="/evenementen.php" id="evenementen">Evenementen</a>
<a href="/fotos.php" id="fotos">Foto's</a>
<a href="/contact.php" id="contact">Contact</a>
<a href="/inschrijvingen.php" id="inschrijvingen">Inschrijvingen</a>
<a href="/partners.php" id="partners">Partners</a>
</div>
</div>
</body>
</html>
It's worth noting that when running this snippet in full screen, the body
appears to adjust its height to match the viewport, causing #menu
to align with the bottom of the viewport as well.
This issue is new to me, despite my previous use of position: absolute;
for similar tasks...
If anyone has a solution to this problem and can explain what might be causing it, I would greatly appreciate your help. Thanks!