如何去除點擊鏈接時出現(xiàn)的虛線框

字號:


    方法一:
    ie 下可使用其私有的html屬性:hidefocus,在標(biāo)簽的結(jié)構(gòu)中加入 hidefocus=”true” 屬性。即:
    <a href=http://www.taobao.com hidefocus=true title=></a>
    而在 firfox 瀏覽器中則相對比較容易,直接給標(biāo)簽 a 定義樣式 outline:none; 就可以了,即:
    .hidefocus {
    outline:none;/*outline:0;也可以*/
    }
    方法二:
    也可以僅用 css 來控制,即對 ie 的情形使用 expression 表達(dá)式,但不推薦使用,畢竟 expression 在性能上有問題。
    .hidefocus {
    hide-focus: expression(this.hidefocus=true); /* for ie 5+ */
    outline: none; /* for firefox 1.5 + */
    }
    opera9 似乎默認(rèn)就不顯示焦點虛線框。
    除鏈接外,該 css 同樣適用于 input 和 button 標(biāo)簽。
    ie6, ie7, ff1.5, ff2, opera9 測試通過。