css - 复选框警报 Controller - 添加 3 个按钮

标签 css typescript sass ionic2 ionic3

我用 IONIC-2 Beta 版制作了一个应用程序。我使用 Checkbox Alert Controller,并添加两个按钮“Okay”和“Cancel”,现在我需要在 Alert Controller 中再添加一个按钮。我在下面实现以再添加一个按钮。

alert.addButton('Cancel');
 alert.addButton({
   text: 'Info',
   role: 'info',
   handler: data => {
     //this.nav.push(DoubleMatPage,{"form_data":this.form_data,"offset":data});
   }
 });
 alert.addButton({
   text: 'Okay',
   handler: data => {
     this.nav.push(DoubleMatPage,{"form_data":this.form_data,"offset":data});
   }
 });

效果很好,但它会像下面那样垂直对齐,

It look like

但是,我想水平对齐它。

如果有人知道解决方案,请帮助我。

谢谢。

最佳答案

您可以使用一些 css 规则来实现。

由于按钮是通过使用 flexbox 对齐的,我们可以覆盖其中一些 css 规则,以便能够在模式中包含三个按钮而不是两个。首先,请注意我在警报中添加了自定义 css 类 (custom-alert),因此我们的 css 规则将影响此警报:

let alert = this.alertCtrl.create({
      cssClass: 'custom-alert',
      ...
});

然后:

.custom-alert button.alert-button-group {
    width: 33.33%;
}

.custom-alert .alert-button-group .button-inner {
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
}

.custom-alert .alert-button-group-vertical {
    -webkit-flex-direction: row;
    -ms-flex-direction: row;
    flex-direction: row ;
}

通过将 width 设置为 33.33% 以允许按钮适契约(Contract)一行,然后将 flex-direction: row 添加到容器而不是默认的 column 值(这就是为什么在您的屏幕截图中按钮显示在列中的原因)。

关于css - 复选框警报 Controller - 添加 3 个按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39179233/

相关文章:

jquery - 允许 jQuery 函数应用于多个标签

reactjs - 如何创建动态 typescript 类型 : The expected type comes from property 'type' which is declared here on type 'AppActions'

css - SASS sourcemaps 在谷歌浏览器中不工作

Laravel Elixir Sass 编译 - .sass 文件

css - SASS 中的元素 > 元素?

javascript - 缺少数字 - CSS inside document.getElementById ("countdown-timer").innerHTML

css - 隐藏 HTML 页面上的滚动条

css - 溢出隐藏添加到 wordpress 网站的首页

angular - 异常 : Uncaught (in promise): Error: Cannot match any routes. URL 段: 'details'

javascript - 使用 [filter, map, some, reduce etc] 从二维数组的子对象创建一维数组