The King is The King is - 2 years ago 82
jQuery Question

Setting a height range between the window top and an element using jQuery

I have an

like this
so that when I load the page the
div name="site"
is highlighted but my problem is that the
stays at the very top of the window which causes some obstruction so is there a way with I can push down the
element by setting a margin between it and the window top for example

$(document).ready(function (){
//set margin between window.height() and div element;

I would also appreciate other methods apart from

Answer Source

You can achieve your aim like this

// the margin can be set to any desired value
margin = 200;
$('html, body').animate({
    scrollTop:$('div').offset().top - margin
}, 2000);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download