在文本后添加内容

Pat*_*Pat 4 css pseudo-element

是否可以通过伪选择器:: after或:: before添加文本到specyfic单词?对于前者 我想在"下载"一词旁边添加pdf图标.[PDF]下载

或者也许是另一种方法?

kRi*_*cha 6

您在pdf上的链接需要包含pdf,然后您可以使用此选择器:

a[href*="pdf"]:before {content: '[ICON] '}
a[href*="pdf"]:after {content: ' ';}
Run Code Online (Sandbox Code Playgroud)
<a href="http://example.com/test.pdf" class="pdf">learn html and css in one week</a>
Run Code Online (Sandbox Code Playgroud)

  • @ehsan 还有很多其他选择器`a[href$=".pdf"]` 尝试使用谷歌 (2认同)