Put title/alt attributes into CSS :after { content: image }?

前端 未结 3 1580
情深已故
情深已故 2021-02-14 10:34

I’ve got the following CSS to add a PDF icon to any link that links to a PDF:

a.pdf-link:after { padding-left: 2px; conte         


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-14 11:18

    No, content only accepts raw text and image data, not HTML.

    You need to use JavaScript to dynamically add tooltips to your existing HTML elements.

    As for the icon, you could use a background image and some padding:

    a.pdf-link {
        padding-left: 2px;
        padding-right: 20px;
        background: url(../images/icon-pdf-link.gif) right center no-repeat;
    }
    

    If you need to specifically have a tooltip only on the icon, though, you need to do everything in JavaScript as the comments say.

提交回复
热议问题