简体   繁体   English

Ionic 3 - 带圆角的模态屏幕

[英]Ionic 3 - Modal screen with rounded corners

How to round a modal screen like this link ?如何圆像这个链接的模态屏幕?

My CSS code is:我的 CSS 代码是:

.modal {
   background: rgba(0, 0, 0, 0.5) !important;
   padding: 25% 15%  !important;
   display: block;
   border-radius: 25px;
 }

modal.html模态.html

   <ion-content>
     <div class="subtitulo">
       <h4>Select your city</h4>
     </div>

    <ion-list>
      <button ion-item *ngFor="let cidade of cidades" (click)="selCidade(cidade)" detail-none>
        <h3 text-wrap>{{ cidade.nome }}</h3>
        <ion-icon name="ios-arrow-forward" item-right></ion-icon>
      </button>
     </ion-list>
   </ion-content>

But the border-radius have no effect.但是边界半径没有影响。 I tried some tutorials, but no one has effect.我尝试了一些教程,但没有一个效果。

I need some help in CSS for this case对于这种情况,我需要一些 CSS 方面的帮助

Tks, tks,

  1. create a css into your css / scss file:在你的 css / scss 文件中创建一个 css:
   .square-modal .modal-wrapper { border-radius: 0px; }
  1. use the css into your model creation:将 css 用于您的模型创建:
  async presentModal() {

    const modal = await this.modalCtrl.create({
      component: InvestorListPage,
      componentProps: { id: 5, name: 'gaurav' },
      cssClass: 'square-modal'
    });

    modal.onDidDismiss().then(result => {
      console.log(result.data);
    });

    return await modal.present();

  }

(tested with ionic4) (用ionic4测试)

Just posting the solution for ionic 4:刚刚发布了ionic 4的解决方案:

in global.scss, just change the scss variable of the ionic component "ion-modal"在 global.scss 中,只需更改离子组件“ion-modal”的 scss 变量

ion-modal {
  --border-radius: 8px!important;
}

if your page is named "modal", you can try adding border-radius: 25px;如果你的页面被命名为“modal”,你可以尝试添加border-radius: 25px; to the page-modal in the modal.scss file:到 modal.scss 文件中的page-modal

page-modal{
   border-radius: 25px;
}

it works perfect for me: example它非常适合我:示例

You can use overflow: hidden .您可以使用overflow: hidden I hope it's will work.我希望它会起作用。

Thanks谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM