html body animate,animation - jQuery ('html.body'),animate not working - Stack Overflow

濮阳唯
2023-12-01

I have a page with three divs. Id like to bring each div into view using animate and the offset positions of each div. I can tell that the link attribute is being passed and I am getting offset numbers. ( verified with window.alerts ) Problem is, the div containers do not move into view.

Here are the links

Content divs

css for content

.main{

width:800px;

padding:10px;

color:#000;

background:rgba(255,255,255,.85);

height:405px;

overflow:auto;

position: relative;

-webkit-border-radius: 20px;

border-radius: 20px;

-moz-box-shadow: 1px 2px 7px rgba(0, 0, 0, 0.35);

-webkit-box-shadow: 1px 2px 7px rgba(0, 0, 0, 0.35);

box-shadow: 1px 2px 7px rgba(0, 0, 0, 0.35);

text-shadow:none;

margin-top:175px;

font-weight:bold;

}

JS:

$(document).ready(function(){

$('#minibar a').click(function(){

var el = $(this).attr('href');

var offset = $(el).offset();

var top = offset.top - 100;

$('body,html').animate({scrollTop:offset.top,scrollLeft:offset.left},500);

return false;

});

});

 类似资料: