jquery 中scrollTop在Firefox下不起作用_html/css_WEB-ITnose
up vote 115 down vote favorite 21 |
This function works fine. It scrolls the body to a desired container's offset function scrolear(destino){ var stop = $(destino).offset().top; var delay = 1000; $('body').animate({scrollTop: stop}, delay); return false;} But not in Firefox. Why? -EDIT- To handle de double trigger in the acepted answer, I suggest stoping the element before the animation: $('body,html').stop(true,true).animate({scrollTop: stop}, delay); |
10 Answers
active oldest votes
up vote 240 down vote accepted |
Firefox places the overflow at the html level, unless specifically styled to behave differently. To get it to work in Firefox, use $('body,html').animate( ... ); Working example The CSS solution would be to set the following styles: html { overflow: hidden; height: 100%; }body { overflow: auto; height: 100%; } I would assume that the JS solution would be least invasive. |
推荐阅读
-
jquery 中scrollTop在Firefox下不起作用_html/css_WEB-ITnose
-
对input【text】的值在jquery中的html()方法在Firefox中得出来为空_html/css_WEB-ITnose
-
在IE9下不起作用?_html/css_WEB-ITnose">
在IE9下不起作用?_html/css_WEB-ITnose
-
在IE9下不起作用?_html/css_WEB-ITnose">
在IE9下不起作用?_html/css_WEB-ITnose
-
jquery 中scrollTop在Firefox下不起作用_html/css_WEB-ITnose
-
对input【text】的值在jquery中的html()方法在Firefox中得出来为空_html/css_WEB-ITnose
-
在字符串资源文件中添加HTML元素,直接使用字符串资源,HTML元素没起作用的解决办法_html/css_WEB-ITnose