[英]Background image on button not showing
I am trying to add background image to a button in ionic framework. 我试图将背景图像添加到离子框架中的按钮。 It works fine in chrome, ios simulator but when I try it on actual device then the background is not showing at all.
它在chrome,ios模拟器中可以正常工作,但是当我在实际设备上尝试时,背景根本不显示。
Here is my template 这是我的模板
<div class="button-container">
<button class="btn-stop" (click)="stop()">
</button>
</div>
And here is my scss 这是我的scss
.button-container {
width: 100%;
position: absolute;
bottom: 9%;
z-index: 1;
}
.btn-stop {
width: 120px;
height: 120px;
background-image: url('../../assets/imgs/bg.png');
background-repeat: no-repeat;
background-color: transparent;
background-size: contain;
&:after {
content: 'DEMAND STOP';
font-size: 2rem;
font-weight: bold;
}
}
No idea why as it is working on other two ie chrome and emulator. 不知道为什么要在其他两个(即chrome和emulator)上运行。
I'll post the answer as I found what was the issue. 我找到问题所在后,我将发布答案。
For iOS device at least, the path to image should be assets/imgs/bg.png
. 至少对于iOS设备,图像路径应为
assets/imgs/bg.png
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.