html - 如何使用结束选择器在链接旁边附加一个图标?

标签 html css

我遇到的问题是我的链接被放置在图标上,因此图标在背景中,而不是我希望的在它旁边。您将如何编写以使图标位于链接的左侧?

HTML:

<p><a href="http://www.scholastic.com/thehungergames/media/hungergames-chapter1.pdf" title="Book  Sample">Hunger Games, Chapter 1</a></p>

CSS:

a[href $=".pdf"] {
    background: url('image.png') no-repeat center left; 
    padding-left 25px;
}

最佳答案

我已经更新了你的代码,它似乎工作得很好..

SEE HERE

a[href$=".pdf"] {
  background: url('http://cdn.cutestpaw.com/wp-content/uploads/2011/11/cute-cat-l.jpg') no-repeat center left; 
  padding-left: 25px; /* you forgot the colon here */
  background-size: auto 100%; /* make the background size 100% of the height of the anchor link */
}

关于html - 如何使用结束选择器在链接旁边附加一个图标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25735507/

相关文章:

弹出窗口的 JavaScript/Jquery 碰撞检测

html - 如何在 reStructuredText 中创建 PDF?

javascript - 如何通过 javascript 从 CSS 类获取样式属性 ime-mode?

javascript - 汉堡菜单下拉低宽度

javascript - 如何垂直和水平对齐 div 中的 img?

css - Controller 中的 ng 风格语法

html - CSS Problem link(a) 属性控制文本颜色

javascript - 如何从删除的可排序元素中获取 div 类名称/id?

复选框 echo 中的php echo

html - 找不到网站的 css 文件