Ionic2 Popover改变宽度

Mis*_*ian 8 ionic-framework ionic2

我想改变只有1页的popover宽度.我试过这个:

我不想$popover-ios-width在variable.scss文件中使用它,因为它改变了所有页面的宽度.

小智 14

@ gabriel-barreto的答案完全没问题.但是,我想在其他版本中需要额外考虑.

在Ionic 3.6中,自定义类被添加到<ion-popover>元素中.要覆盖类中的默认宽度规则集.popover-content,您的选择器应为:

.custom-popover .popover-content {
  width: 60%;
}
Run Code Online (Sandbox Code Playgroud)


Gab*_*eto 13

您可以仅为此弹出窗口创建自定义类,并将其传递cssClass给它的选项

让我们说你有这个:

.custom-popover {
  width: 60%;
}
Run Code Online (Sandbox Code Playgroud)

在弹出窗口创建中,您只需将其作为选项插入cssClass即可

const customPopOver = this.popover.create({ yourPopoverPage, yourData, { cssClass: 'custom-popover'}});
customPopOver.present();
Run Code Online (Sandbox Code Playgroud)

希望这会有所帮助:D

  • 正如@afifahmi所说它需要全局,将你的.customer-popover放在app文件夹里的`app.scss`文件中. (3认同)