答案 0 :(得分:5)
您可以使用具有自定义类名的离子模态,因此您只为此弹出窗口覆盖css
打开弹出窗口:
openModal() {
let modal = this.modalCtrl.create(CustomPopup,{},{showBackdrop:true, enableBackdropDismiss:true});
modal.present();
}
模态中使用的组件:
import { Component, Renderer } from '@angular/core';
import { ViewController } from 'ionic-angular';
@Component({
selector: 'custom-popup',
templateUrl: 'custom-popup.html'
})
export class CustomPopup {
text: string;
constructor(public renderer: Renderer, public viewCtrl: ViewController) {
this.renderer.setElementClass(viewCtrl.pageRef().nativeElement, 'custom-popup', true);
}
}
最后是SCSS:
ion-modal.custom-popup ion-backdrop {
visibility: visible !important;
z-index:0;
}
ion-modal.custom-popup .modal-wrapper{
top: 20%;
width:60%;
height:300px;
position:absolute;
}
答案 1 :(得分:0)
您可以添加如下创建自定义控制器 -
import { AlertController } from 'ionic-angular';
constructor(private alertCtrl: AlertController) {
}
presentAlert() {
let alert = this.alertCtrl.create({
title: 'Low battery',
subTitle: '10% of battery remaining',
cssClass: 'my-class',
buttons: ['Dismiss']
});
alert.present();
}
<style>
.my-class{
background: gray;
color:#333;
}
</style>
以同样的方式添加自定义样式。您可以获得完整的示例 - https://www.tutorialsplane.com/ionic-popup