You can do this with jquery.
First you need to include the jquery <head> f you aint library.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
as per the above, you need the following javascript
<script type="text/javascript"> $(function(){ $('a[href*=#]').click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { var $target = $(this.hash); $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']'); if ($target.length) { var targetOffset = $target.offset().top - 300; $('html,body').animate({scrollTop: targetOffset}, 10); return false; } } }); }); </script>
The next line from the above script controls the offset or "margin" on top.
var targetOffset = $target.offset().top - 300;
You can also make the scroll smooth by increasing the value on this line.
$('html,body').animate({scrollTop: targetOffset}, 10);
try replacing it with this.
$('html,body').animate({scrollTop: targetOffset}, 1000);
source share