Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic 3 - I want a modal screen not full size

I need a modal page with no full size (80% width, <60% height, centered) to select some items, like an alert control. How to implement the CSS for this case?

like image 232
Murilo Avatar asked Mar 09 '18 02:03

Murilo


3 Answers

Initialize modal with cssClass

 let modal = this.modalCtrl.create(CustomSelectPage, {data: data}, {cssClass: 'select-modal' });

Then add CSS to the class in app.scss

.select-modal {
   background: rgba(0, 0, 0, 0.5) !important;
   padding: 20% 10%  !important;
}

Change the numbers according to your design.

like image 87
Swapnil Patwa Avatar answered Oct 19 '22 02:10

Swapnil Patwa


put this code only in your component css file

::ng-deep .sc-ion-modal-md-h {
--width: 90%;
--height: 70%;
  }
like image 25
Shashwat Gupta Avatar answered Oct 19 '22 00:10

Shashwat Gupta


in TS file:

  async MyModal() {
    const modal = await this.modalController.create({
      component: MyModalPage,
      backdropDismiss: true,
      cssClass: 'my-modal',
    });
    return await modal.present();
  }

in SCSS file:

.my-modal {
  --width: 70%;
  --height: 35%;
}
like image 34
Shravan Avatar answered Oct 19 '22 00:10

Shravan