[英]Ionic 4 - How to change modal background to transparent?
我正在尝试创建一个具有透明背景的模态,但它不起作用
ion-content { --background-color: rgba(255, 255, 255, 0.7); } .closeBtn { position: absolute; bottom: 0px; left: 0px; right: 0px; }
<ion-content padding> <h3 class="ion-text-center"> <strong>Test.</strong> </h3> <ion-button class="closeBtn" color='light' fill='clear'>Close</ion-button> </ion-content>
我希望看到一些透明度。
全局文件
.modal-wrapper{
background: transparent !important;
}
页面.scss
ion-content{
--background: transparent;
}
也许只是:
ion-content {
background-color: rgba(255, 255, 255, 0.7);
}
您可以通过更改ion-modal
--ion-background-color
变量来ion-modal
:
ion-modal {
--ion-background-color: #ffffff85;
}
global.scss
.modal-wrapper, .inner-scroll {
background: transparent !important;
}
你的页面.scss
ion-content {
--background: transparent !important;
}
您可以将 css 类应用于您的模态(此处为 phone-modal),然后覆盖 global.scss 中的离子基本样式
const modal = await this.modalCtrl.create(
{
component: PhoneContactModalComponent,
cssClass: 'phone-modal'
});
global.scss :
.phone-modal {
padding: 35vh 30px 20vh 30px;
background: rgba(0, 0, 0, 0.5);
}
.sc-ion-modal-md-h {
--background: none;
}
.sc-ion-modal-ios-h {
--background: none;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.