html - 将锚的背景图像定位在锚文本的左侧?
问题描述
我正在尝试获取我为锚设置的背景图像作为图标,在锚文本旁边并调整大小 - 以便图像和文本彼此对齐,但我不确定如何去做这个。
代码:
a {
font-family: sans-serif;
font-size: 14pt;
}
<a style="background: url('https://cdn1.iconfinder.com/data/icons/ninja-things-1/1772/ninja-simple-128.png');">
Text here
</a>
解决方案
试试这个代码。
a {
font-family: sans-serif;
font-size: 14pt;
background-image: url('https://cdn1.iconfinder.com/data/icons/ninja-things-1/1772/ninja-simple-128.png');
background-size: 15px;
background-repeat: no-repeat;
background-position: left;
padding-left: 15px;
}
<a href="#">Text here</a>
推荐阅读
- google-sheets - Google API 强制英语响应消息
- c - 为什么signed char的值大于unsigned int
- python - 无法使用“/usr/bin/env”创建进程
- javascript - JS Graph递归与迭代DFS顺序差异
- node.js - 如何防止 nodeJs 中的多个贝宝付款?
- javascript - 试图找到每个父级的嵌套元素的数量
- go - Go 模块导入 - 无效版本:go.mod 的模块路径格式错误
- python - 在 Numpy Python 中过滤掉日期数组
- django - 检查Django的ManyToManyField中是否存在用户类型?
- google-api-dotnet-client - Google.Apis.Dfareporting.v3_3 仅获取帐户的活动配置文件