我在页面顶部有一个按钮,链接到 /#tabs (id="tabs" 的索引)。它使用脚本来平滑地滚动到该 ID,但它会将 URL 更改为 www.domain.com/#tabs。我该如何删除 #tabs 部分?我考虑在 .htaccess 中完成,但不确定是否可行,而且这可能是个坏主意。
以下是 HTML 代码:
以下是 HTML 代码:
<a class="smoothscroll" href="/#tabs">
<div class="scroll-down"></div>
</a>
</header>
<br />
<div id="tabs" style="padding:20px;"></div>
<div class="tabs">
<h1>About</h1>
<div class="p">
about us
<a href="/contact"><input type="submit" value="Contact Us" class="btn" name="contact" style="min-width:15%;"/></a>
</div>
</div>
<a class="smoothscroll" href="/#tabs">
<div class="scroll-down"></div>
</a>
,并使用该脚本平滑滚动。<script>
/*----------------------------------------------------*/
/* Quote Loop
------------------------------------------------------ */
function fade($ele) {
$ele.fadeIn(1000).delay(3000).fadeOut(1000, function() {
var $next = $(this).next('.quote');
fade($next.length > 0 ? $next : $(this).parent().children().first());
});
}
fade($('.quoteLoop > .quote').first());
/*----------------------------------------------------*/
/* Smooth Scrolling
------------------------------------------------------ */
jQuery(document).ready(function($) {
$('.smoothscroll').on('click',function (e) {
e.preventDefault();
var target = this.hash,
$target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top
}, 800, 'swing', function () {
window.location.hash = target;
});
});
});
TweenMax.staggerFrom(".heading", 0.8, {opacity: 0, y: 20, delay: 0.2}, 0.4);
</script>
忘记脚本顶部的部分,那只是索引的一部分。