Search code examples
htmlcssnavigationmenubarzooming

Browser zoom crashes my vertical navbar


I got a problem that's related to the built in browser zoom (ctrl + scroll). Im about to build a site with a vertical navigation bar along the left side, which is pretty standard stuff... Everything looks fine with the listobjects seperated by a "border-bottom: 1px solid black". The listobjects are perfectly positioned down to the bottom of the parent-div.

This is until I start checking my page with the browser zoom. Then the border at the bottom of the last listobject "jumps" down a notch and gets placed below the parent-div... And if I continue zooming in the site jumps a little uncontrollably.

Does anyone have a solution to this? (Pasting my code below)

* {
	margin: 0;
	padding: 0;
}

body {
	background-color: lightblue;
}

div#wrapper {
	width: 1300px;
	height: 600px;
	border: 1px solid black;
	margin: 20px auto 0px auto;
}

div#header {
	width: 100%;
	height: 100px;
	border-bottom: 1px solid black;
	background-image: url(".././bilder/headerBG.jpg");
}

div#header > h1 {
	color: white;
	padding-top: 15px;
	text-align: center;
	font-size: 55px;
	font-family: Algerian, "Times New Roman";
}

div#navbar {
	width: 300px;
	height: 500px;
	border-right: 1px solid black;	
}

div#navbar > ul {
	text-align: center;
}

div#navbar > ul > li {
	list-style-type: none;
	border-bottom: 1px solid black;
	font-size: 25px;
}
  
div#navbar > ul > li > a {
	color: black;
	text-decoration: none;
	display: block;
	box-sizing: border-box;
	width: 100%;
	padding: 35.5px 0;
}

div#content {
	width: 1000px;
	height: 500px;
	float: right;
}

div#footer {
	width: 1300px;
	height: 50px;
	margin: 0px auto;
	border-left: 1px solid black;
	border-bottom: 1px solid black;
	border-right: 1px solid black;
	clear: both;
}
      <div id="wrapper">
			<div id="header">
				<h1>Hello DIV</h1>
			</div>
			<div id="navbar">
				<ul>
					<li><a href="#">Start</a></li>
					<li><a href="#">About</a></li>
					<li><a href="#">Vision</a></li>
					<li><a href="#">Services</a></li>
					<li><a href="#">Contact</a></li>
				</ul>
			</div>
			<div id="content">
				
			</div>
		</div>
	
        <div id="footer">
				
		</div>


Solution

  • Hi I just checked your Css and the problems are due to Height given to the following divs :

    #wrapper & #navbar 
    

    There is a blank div called #content because of which you see a notch which goes down !! To avoid it remove height from #content too