更改离子弹出窗口的宽度

5 html css popup ionic-framework

我想在我的 ionic 项目中更改特定弹出窗口的宽度,而不会对其他项目产生影响。

 var alertPopup = $ionicPopup.alert({
     cssClass: 'popupg',
      title: coe,
      template: text
    });
Run Code Online (Sandbox Code Playgroud)

Ami*_*Dev 5

如果您使用的是 Ionic 3

在您的 .ts 文件上:

    const alert = await this.alertCtrl.create({
        header: 'Sorry',
        cssClass: 'my-custom-alert',
        message: 'message',
        buttons: ['Find by name ?']
    });
Run Code Online (Sandbox Code Playgroud)

在您的 global.scss 上

.my-custom-alert .alert-wrapper {
  min-width: 450px !important;
}
Run Code Online (Sandbox Code Playgroud)

样式前的弹出窗口: 在此处输入图片说明

样式后弹出窗口(最小宽度:450 像素)

在此处输入图片说明

我希望这会有所帮助:)


小智 1

你可以添加style.css,像这样。

<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
Run Code Online (Sandbox Code Playgroud)

您需要修改弹出宽度。

样式.css

/**
 * Popups
 * --------------------------------------------------
 */
  .popup-container .popup {
    width: 350px;
 }
Run Code Online (Sandbox Code Playgroud)

想帮助你。