esc*_*ner 3 javascript smooth-scrolling twitter-bootstrap
虽然有人问了几次,但我找不到能解决问题的方法.
这是我的平滑滚动代码:
$(function() {
$('a[href*=#]:not([href=#]),a[href*=#]:not(a[data-toggle])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
Run Code Online (Sandbox Code Playgroud)
这是css-tricks代码,有点编辑.这是网站:http://redrocketwebsitedesign.co.uk/test/my3DtwinAlpha/about/#arrow6
所以手风琴仍然被选中用于滚动,并且它没有运行手风琴js.我认为我的javascript没有选择器代码存在问题:
a[href*=#]:not(a[data-toggle])
任何帮助表示赞赏: - ]
小智 5
这就是你真正想要的:
$('a[href*="#"]:not([href="#"]):not([data-toggle])').click(function() {
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
if (target.length) {
$('html, body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
Run Code Online (Sandbox Code Playgroud)
:not([data-toggle]) 是为了避免使用bootstrap tab,carousel等进行平滑滚动...
| 归档时间: |
|
| 查看次数: |
4071 次 |
| 最近记录: |