我目前正在使用这个插件:http://github.com/davist11/jQuery-One-Page-Nav
但更愿意转而使用Twitter的Bootstrap.js Scrollspy:http://twitter.github.com/bootstrap/javascript.html#scrollspy
但是,这不提供在单击时为滚动动画设置动画的选项.我该如何添加?
我创建了一个jQuery函数,通过减少元素的左边距来滚动DIV.它有效,但速度非常慢.它立刻吃掉了100%的CPU:s
$(".scroll").hover(
function () {
var scroll_offset = parseInt($('#content').css('margin-left'));
sliderInt = self.setInterval(function(){
$content.css({'margin-left':scroll_offset+'px'});
scroll_offset--;
},8);
},
function () {
clearInterval(sliderInt);
}
);
Run Code Online (Sandbox Code Playgroud)
显然我每隔8ms运行一次这个功能,这是很多问题.我已经缓存了我的选择器,所以我不知道我能做些什么来提高性能.我只是走错了路吗?
我怎样才能这样做,当你向下滚动页面时,下一个DIV会在之前的顶部消失?
我已经设置了这个小提琴来更好地说明它:http://jsfiddle.net/meEf4/176/
因此,例如,如果你在页面中间,背景为蓝色.
编辑:这是jsFiddle的内容,如果爆炸,有人遇到类似的问题.
<style>
html, body, #red, #green, #blue { height: 100%}
#container { height: 300%}
#red, #green, #blue {
position: fixed;
top: 0;
width: 100%;
}
#red { background:red; z-index: 5}
#blue { background:blue; z-index: 4}
#green { background:green; z-index: 3}?
</style>
<div id="container">
<div id="red"></div>
<div id="blue"></div>
<div id="green"></div>
</div>?
Run Code Online (Sandbox Code Playgroud) 我试图按字母顺序对一系列名称进行排序(在本例中为克罗地亚语).
我怎么才能?ani出现Derrick呢?
$names = array(
"?ani", "Bill", "Dennis", "George", "Derrick"
);
sort($names);
print_r($names);
Run Code Online (Sandbox Code Playgroud)