“text-decoration” and the “:after” pseudo-element, revisited

后端 未结 11 946
旧巷少年郎
旧巷少年郎 2020-11-27 18:43

I\'m re-asking this question because its answers didn\'t work in my case.

In my stylesheet for printed media I want to append the url after every link using the

11条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-27 19:27

    I realise this isn't answering the question you're asking, but is there a reason you can't use the following (background-based approach):

    a.file_pdf {
    background-image: url(images/pdf.png);
    background-position: center right;
    background-repeat: no-repeat;
    padding-right: 15px; /* or whatever size your .png image is plus a small margin */
    }
    

    As far as I know, the Firefox implementation of :after observes the property of the selector's class, not the psuedo-class. It might be worth experimenting with different doctypes, though? The transitional, rather than strict, sometimes allows for different results (albeit not always better results...).

    Edit:

    It appears that using

    a:after {
        content: " <" attr(href) ">";
        text-decoration: none;
        color: #000000;
        background-color: #fff; /* or whatever colour you prefer */
    }
    

    overrides, or at least hides, the text-decoration. This doesn't really provide any kind of answer, but at least offers a workaround of sorts.

提交回复
热议问题