HTML Anchor, Disable Style

后端 未结 3 452
悲&欢浪女
悲&欢浪女 2021-02-06 21:48

I have some html anchor link code, and unlike the rest of document I want it to look like it is not a link.

Is there a simple way to disable the style change caused by w

3条回答
  •  Happy的楠姐
    2021-02-06 22:41

    If you don't care about IE, you can attach :not(#exclude) (where exclude is the ID of the link in question) to your link styles:

    a:link:not(#exclude), a:visited:not(#exclude) {
        text-decoration: none;
        color: blue;
        cursor: pointer;
    }
    

    Otherwise I don't think you can brute-force it the way you describe. You can either use an inline style instead (not recommended) or you can use a special class/ID assigned to that link, whose selector you'd group with body. For example, if you had these styles:

    body {
        text-decoration: none;
        color: black;
        cursor: auto;
    }
    
    a:link, a:visited {
        text-decoration: none;
        color: blue;
        cursor: pointer;
    }
    

    You can simply toss in a more specific selector, that'd match that link, onto the body rule:

    body, #exclude {
        text-decoration: none;
        color: black;
        cursor: auto;
    }
    
    a:link, a:visited {
        text-decoration: none;
        color: blue;
        cursor: pointer;
    }
    

提交回复
热议问题