使用引导程序,我在这里设置了一个示例:http: //fixitup.com.au/clients/bootstrap/issue.html
使用滚动到主站点,以及 twitter 引导程序、选项卡。我发现当您单击选项卡时,页面会跳起来。
我添加onclick="return false;"
到标签的href。
喜欢:
<ul id="myTab" class="nav nav-tabs">
<li class="active"><a href="#about" data-toggle="tab" onclick="return false;">About Me</a></li>
<li><a href="#ripoffs" data-toggle="tab" onclick="return false;">My Ripoffs</a></li>
</ul>
我需要滚动,我需要标签......但我需要停止页面跳转,它让我发疯。有什么建议么 ?
补充:滚动的js在下面的aruo.js代码中:
// Any links with hash tags in them (can't do ^= because of fully qualified URL potential)
$('a[href*=#]').each(function() {
// Ensure it's a same-page link
var thisPath = filterPath(this.pathname) || locationPath;
if ( locationPath == thisPath
&& (location.hostname == this.hostname || !this.hostname)
&& this.hash.replace(/#/,'') ) {
// Ensure target exists
var $target = $(this.hash), target = this.hash;
if ($(target).length > 0) {
// Find location of target
var targetOffset = $target.offset().top;
$(this).click(function(event) {
// Prevent jump-down
event.preventDefault();
// Animate to target
$(scrollElem).animate({scrollTop: targetOffset}, 1100, 'swing', function() {
// Set hash in URL after animation successful
location.hash = target;
});
});
}
}
});
// Use the first element that is "scrollable" (cross-browser fix?)
function scrollableElement(els) {
for (var i = 0, argLength = arguments.length; i <argLength; i++) {
var el = arguments[i],
$scrollElement = $(el);
if ($scrollElement.scrollTop()> 0) {
return el;
} else {
$scrollElement.scrollTop(1);
var isScrollable = $scrollElement.scrollTop()> 0;
$scrollElement.scrollTop(0);
if (isScrollable) {
return el;
}
}
}
return [];
}
});