【发布时间】:2018-12-18 10:10:06
【问题描述】:
我有 ASP.NET Core 项目并想向其中添加 SVG 图标
我在wwwroot/images/MainSystem/Reports下添加了
我在项目和资源管理器中看到了它
在这之后,我写了一段 css 代码在后台使用它们
这里是代码
.child.devices {
background-image: url(../images/MainSystem/Reports-icons/Devices.svg);
background-position: center;
background-repeat: no-repeat;
background-size: 150px;
}
并在 HTML 中这样使用
<div class="child devices"><span>Devices</span></div>
但图像没有出现。但我看到它的风格
我在控制台中没有错误
我尝试清理项目并重建和清理缓存。
什么都没有发生。我该如何解决这个问题?
【问题讨论】:
-
如果你在浏览器中访问
/images/MainSystem/Reports-icons/Devices.svg会发生什么? -
要知道链接是否正确:右键单击链接(开发者控制台),然后选择“在新标签中打开”,如果图片没有出现在新标签中则链接错了
-
我看到这张图片@Alex
-
试着给你的
.child.devices一个宽度和高度,比如500px,看看你能不能看到背景 -
尝试将
background-size: 150px;更改为background-size: 150px 150px;
标签: html css asp.net asp.net-mvc