How to remove only underline from a:before?

后端 未结 6 1926
一整个雨季
一整个雨季 2020-12-02 12:38

I have a set of styled links using the :before to apply an arrow.

It looks good in all browser, but when I apply the underline to the link, I don\'t wan

6条回答
  •  一生所求
    2020-12-02 13:30

    There is a Bug in IE8-11, so using display:inline-block; alone won't work there.

    I've found a solution for this bug, by explicitly setting text-decoration:underline; for the :before-content and then overwrite this rule again with text-decoration:none;

    a {text-decoration:none;}
    a:hover {text-decoration:underline;}
    a:before {content:'>\a0'; text-decoration:underline; display:inline-block;}
    a:before,
    a:hover:before {text-decoration:none;}
    

    Working example here: http://jsfiddle.net/95C2M/

    Update: Since jsfiddle does not work with IE8 anymore, just paste this simple demo-code in a local html file and open it in IE8:

    
    
    
        demo
        
    
    
        Testlink With no Underline on hover under before-content
    
    
    

提交回复
热议问题