【发布时间】:2011-02-12 01:59:43
【问题描述】:
我正在使用 Jquery 使图像在我的页面上水平滚动。唯一的问题是它使用了大量的 CPU。在 Firefox 中的单核笔记本电脑上高达 100%。 这可能是什么原因???
jquery
<script>
jQuery(document).ready(function() {
$(".speech").animate({backgroundPosition: "-6000px 0px"}, 400000, null);
});
</script>
CSS
.speech {
/*position:fixed;*/
top:0;
left:0px;
height:400px;
width:100%;
z-index:-1;
background:url(/images/speech.png) -300px -500px repeat-x;
margin-right: auto;
margin-left: auto;
position: fixed;
}
HTML
<div class="speech"></div>
【问题讨论】:
-
真的很危险吗?我从来没有遇到过这样的记忆猪。你使用的是什么浏览器?我无法复制问题。尝试同样的方法,但不要使用 png - 尝试使用 gif/jpg 来代替,看看是否有同样的问题。
-
他没有说这是一个记忆猪;这不是 100% CPU 利用率的意思。
标签: javascript jquery jquery-animate cpu-usage