【发布时间】:2015-10-26 15:35:52
【问题描述】:
我的引导轮播的左右控制脚本与平滑页面滚动脚本发生冲突。
我确实测试了在 stackoverflow 中找到的另一个解决方案。轮播工作正常,但流畅的页面滚动确实停止工作。
原来的工作卷轴:
<script>
$(function() {
$('a[href*=#]:not([href=#])').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
}, 500);
return false;
}
}
});
});
</script>
破坏页面平滑滚动的stackoverflow“解决方案”:
Change:
$('a[href*=#]:not([href=#])').click(function() {
to (if you use the ID header-menu):
$('#header-menu a[href*=#]:not([href=#])').click(function() {
or (if you use the class header-menu):
$('.header-menu a[href*=#]:not([href=#])').click(function() {
错误解决方案的网址:click here
我想知道如何让 carousel 和 smooth scoll 同时工作。
【问题讨论】:
标签: twitter-bootstrap carousel smooth-scrolling