我正在使用Jquery让一张图片在我的网页上水平滚动。唯一的问题是它会消耗大量的CPU资源。在Firefox浏览器中,单核笔记本电脑的CPU使用率可高达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>