2013-12-12 24 views
2

我正在使用jQuery滾動條滾動到頁面上的某個元素。在這種情況下,它是Navbar。不過,我遇到了一個奇怪的問題。點擊按鈕滾動到元素後,結果元素將生成focus屬性。平滑滾動生成:目標div上的活動屬性

enter image description here

這會消失,當我點擊並取消勾選元素再次出現。它只發生在我點擊按鈕滾動到這個位置之後。我曾嘗試針對重點標籤div和它聲明.navbar:focus { box-shadow: none;}但它不工作

我使用下面的產生的滾動效應,感到 <a href="#navigationtop" class="anchorLink">

jQuery(function($) { 

    var scrollElement = 'html, body'; 
$('html, body').each(function() { 
    var initScrollTop = $(this).attr('scrollTop'); 
    $(this).attr('scrollTop', initScrollTop + 1); 
    if ($(this).attr('scrollTop') == initScrollTop + 1) { 
    scrollElement = this.nodeName.toLowerCase(); 
    $(this).attr('scrollTop', initScrollTop); 
    return false; 
    }  
    }); 

    // Smooth scrolling for internal links 
    $("a[href^='#']").click(function(event) { 
    event.preventDefault(); 

var $this = $(this), 
target = this.hash, 
$target = $(target); 

$(scrollElement).stop().animate({ 
    'scrollTop': $target.offset().top 
}, 500, 'swing', function() { 
    window.location.hash = target; 
}); 

}); 

}); 
+0

你是什麼意思'結果元素生成焦點屬性'? – MElliott

+0

有沒有這樣的事情作爲一個HTML元素的'焦點'屬性..以及如何一個元素爲自己生成一個屬性?沒有意義。 – MElliott

+0

多數民衆贊成最好的方式,我可以形容它.....當我點擊它,它添加我認爲,一個盒子的影子,但只有在按鈕滾動已被預先 – memyselfandmyiphone

回答

0

瞄準元素在您master.css文件,你有一個樣式定義:

.navbar-default {background: #F7F7F7!important; 
border: none!important; 
box-shadow: 0 0 10px #888 
-moz-box-shadow: 0 0 10px #888; 
-webkit-box-shadow: 0 0 10px #888; 
font-family: 'Oswald', sans-serif!important; 
} 

試試這個:

添加outline: none;這個樣式定義。

+0

沒有運氣布賴恩。這針對我想保持的影子。灰色#888。我需要點擊滑塊後出現的導航欄上的藍色以消除 – memyselfandmyiphone

+0

hm。我不完全確定你指的是什麼..你使用什麼瀏覽器? – MElliott

+0

我編輯了我的答案。我不完全確定這是否是你指的是,但試試看.. :) – MElliott