版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/AndyNikolas/article/details/79471657
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<style>
a[href $='.pdf'] {
padding-right: 20px;
background: transparent url(http://www.iconpng.com/png/lozengue-filetype/pdf.png) no-repeat right;
background-size: contain;
}
</style>
<body>
<a href="godkun.pdf">pdf文件</a>
</body>
</html>
示意图如下:
对background进行分析:
transparent
是指背景颜色设置为透明色- 背景
url
图片是默认填的区域大小为width
的值,如果是边框盒模型,就是包括padding
和border
no-repeat
是不重复图片来填充区域,只填充一个right
是指填充在背景区域的最右侧
对a[href $='.pdf']
进行分析:
href
指定a
标签的链接类型$
表示结束的位置,用于正则$='.pdf'
是指匹配以.pdf
结尾的href
链接