problem in scrolling
Hello friends
I have a question.
I'm using this code for a website I'm building.
It works. But there is something that bothers me.
When I scroll down the window a little, there is a kind of "jump" downwards. What do I need to change in the code so that it doesn't exist?
<!DOCTYPE html>
<html>
<head>
<title>Sticky Navbar</title>
<style>
body {
margin: 0;
}
.fixit {
position: fixed;
top: 0;
}
.main_navigation {
background-color: #000;
width: 200px;
color: #fff;
}
.main_navigation h3 {
margin: 0;
}
header, .content {
width: 85%;
margin: 0 auto;
}
</style>
</head>
<body>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script>
$(document).ready(function() {
var fixit = "fixit";
var height = $('header').height();
$(window).scroll(function() {
if ($(this).scrollTop() > height) {
$(".main_navigation").addClass(fixit);
} else {
$(".main_navigation").removeClass(fixit);
}
});
});
</script><!-- end header -->
<nav class="main_navigation">
<table width="200" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>Navigation goes here <a href="#link1">בב</a></td>
</tr>
</tbody>
</table>
</nav>
<table width="200" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td height="244" bgcolor="#9D4446"><p> </p>
<p>ב</p>
<p>ב</p>
<p>ב</p>
<p>בב</p>
<p>ב</p>
<p>ב</p>
<p>ב</p>
<p>ב</p>
<p>ב</p>
<p>ב</p>
<p>ב</p>
<p>ב</p>
<p>ב</p>
<p>ב</p>
<p>ב</p>
<p>בב</p>
<p>ב</p>
<p>ב</p>
<p>ב</p>
<p>ב</p>
<p>ב</p>
<p>ב</p>
<p id="link1"> </p>
<p> </p>
<p>This is a line of <strong>3333</strong></p>
<p>ב</p>
<p>ב</p>
<p> </p></td>
</tr>
</tbody>
</table>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</body>
</html>

