2012-12-22 43 views
4

我一直在搞JS和CSS。 我有一個通用按鈕樣式的錨點。 在造型中,我有一個border-bottom: 5px dotted blue;。 那麼JS是:FireFox中的奇怪邊框錯誤

onmouseover = "this.style.borderBottom = '5px solid red';" 

他是的jsfiddle例子:http://jsfiddle.net/MichaelMitchell/f4Ud4/ 懸停在按鈕上方

邊框似乎重疊,可能有人請解釋一下嗎? 由於Chrome處理虛線邊框的方式,這隻在FireFox中可見。

+0

看起來像一個bug。當你離開標籤,回來一切都很好。如果你願意,你可以在[Bugzilla](https://bugzilla.mozilla.org/)上報告。 – Pavlo

回答

2

我無法解釋車的行爲。當另一個邊框被繪製時,firefox顯然不會清除繪圖區域。

但這裏有一個(髒)解決方案

<a class = 'testButton' href = '#' 
    onmouseover = 
    "var button = this; button.style.borderBottom = '0px'; setTimeout(function() { button.style.borderBottom = '5px solid red'; }, 1)"> 
    Button! 
</a> 
+0

將變量'button'設置爲'this'是什麼原因? – MichaelMitchell

+0

'var button'需要訪問回調函數中的元素,'this'won't指向預期的元素 – bukart

+0

我看到,'function(){}'位 – MichaelMitchell