html - 将 svg 居中对齐到具有灰色背景的按钮
问题描述
我有一个带有要对齐到中心的图像的按钮。我希望按钮具有灰色背景。
HTML:
<button type="submit" data-target="#modal">
<img className="rainbow" role="presentation" />
</button>
CSS:
.rainbow {
background: url("/static/icons/arrow.svg") no- repeat center;
border: none;
cursor:pointer;
overflow: hidden;
outline:none;
height: 53px;
width: 50px;
background-color: $welcome-gray-1;
}
解决方案
您不需要内嵌图像,并且需要将背景应用于按钮元素。
button {
background: #000 url("/static/icons/arrow.svg") no-repeat center;
border: none;
cursor: pointer;
overflow: hidden;
outline: none;
height: 53px;
width: 50px;
}
<button type="submit" data-target="#modal" />
推荐阅读
- python-3.x - 如何根据多个键对嵌套字典进行排序
- jquery - jQuery滚动功能上的CSS边框消失
- r - devtools::install_github 错误:SEC_E_UNTRUSTED_ROOT - 证书链由不可靠的实体颁发
- php - linux cronjob在一行中包含多个php文件
- wordpress - 我的图标字体未加载,并且在我将站点从本地主机部署到 live 后返回 CORS 错误
- java - 通过 aspectJ 和 byte-buddy 代理检测编织类
- c# - 来自反序列化 JSON 的 DateTime 值被编译器视为字符串和日期时间
- python - 遍历多层字典
- oracle-apex - 从 APEX 数据上传向导的下拉列表中填充列
- switch-statement - 如何在该程序中添加“小于”语句