html - CSS 样式。在链接前放一个箭头图像

标签 html css

链接文本右对齐。我想将箭头图像放在链接文本之前,但不想链接图像。我在帖子中放了一个打印照片的例子。

#submitYourConcern {
  background: url( '/_layouts/images/grey_arrow.png' ) no-repeat right;
  padding-right: 15px;
  color: #4b92db;
  text-align: right;
}
<div id="submitYourConcern">
  <a href="/submit.aspx">Submit Your Concern</a>
</div>

enter image description here

最佳答案

您可以使用 ::before 将内容放在元素之前。

#submitYourConcern
    {       
        background: url(/_layouts/images/grey_arrow.png) no-repeat right ;
        padding-right: 15px;
        color: #4b92db;
        text-align: right;
    }
#submitYourConcern::before {
    content: ">";
    display:inline-block;
}
<div id="submitYourConcern">
<a href="/submit.aspx">Submit Your Concern</a>
</div>

如果要使用图片,可以使用background-image

关于html - CSS 样式。在链接前放一个箭头图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43208518/

相关文章:

javascript - 如何在 JavaScript 中检测月份变化?

html - IE9+ 不喜欢媒体查询 css

css - Foundation Zurb 中的图像缩放

html - CSS 中的多个点/句点

html - 当内容肯定离开页面时,为什么这个滚动条会变灰?

javascript - 除了某些元素之外,我可以模糊整个网站吗

c# - 如果搜索框位于 _SiteLayout 页面(在标题 DIV 中),如何将搜索结果返回给用户

css - JavaFX 如何更改对话框/窗口标题的颜色?

CSS Transition延迟显示bootstrap 3菜单

php - 如何修改文本框区域内的一些数据