我想使用图像作为角度的span标签中的背景:
.iti-flag {
display: inline-block;
width: 20px;
height: 15px;
margin-right: 5px;
background-image: url("src/assets/img/flags/flags.png");
background-repeat: no-repeat;
background-color: #dbdbdb;
background-position: 20px 0;
}
@media only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and (min--moz-device-pixel-ratio: 2),
only screen and (-o-min-device-pixel-ratio: 2 / 1),
only screen and (min-device-pixel-ratio: 2),
only screen and (min-resolution: 192dpi),
only screen and (min-resolution: 2dppx) {
.iti-flag {
background-image: url("src/assets/img/flags/flags.png");
}
}
这是我要为背景成像的span标签:
<span [class]="'iti-flag iti-flag-selected ' + selectedCountry.flagClass" matPrefix></span>
但是在“网络”标签中,我跟踪了它,它是以文本/纯格式加载的,因此我需要按图像格式显示该图像。
出什么问题?我该如何解决这个问题?
答案 0 :(得分:2)
从您的路径中删除src
并尝试这样做。
background-image: url("/assets/img/flags/flags.png");