【问题标题】:Way to add or apply multiple classes for ngx-bootstrap modal为 ngx-bootstrap 模态添加或应用多个类的方法
【发布时间】:2020-08-26 17:19:15
【问题描述】:

我想以大格式显示一个 ngx-bootstrap 模态。

为此有两个类:modal-dialog-centeredmodal-lg,但我看不出有任何方法可以同时应用这些类。

在这里查看ngx-bootstrap source code 时:modal-options.class.ts

有一个可选的class property 定义为class?: string;。但它没有定义为我们可以应用的类数组。

所以现在我可以显示居中的模态:

this.bsModalRef = this.modalService.show(ConfirmationComponent,
    {class: 'modal-dialog-centered', initialState});

或大模态但不居中:

this.bsModalRef = this.modalService.show(ModalConfirmationComponent,
    {class: 'modal-lg', initialState});

我尝试将此添加到模态的开始模板:

<div class="modal-dialog modal-lg">
  <div class="modal-content">
    <div class="modal-header">
    ...

但也没有运气,modal-lg 的班级不想工作

有人知道如何让它工作吗?

更新

这个 CSS 看起来会给出一些结果,但表现得并不完全好:

::ng-deep .modal.show .modal-dialog {
  -webkit-transform: translate(50%, 50%);
  transform: translate(0%, 50%);
}

【问题讨论】:

  • {class: 'modal-dialog-centered modal-lg', initialState}..?
  • @MikeOne:是的,它就是这样工作的,官方文档中是否对此进行了解释?

标签: css angular ngx-bootstrap ngx-bootstrap-modal


【解决方案1】:

@MikeOne 提供的建议非常有效。

因此,添加空格分隔的类将提供向模态应用多个类的能力。

我们可以使用以下代码显示完全居中且大的模态:

this.bsModalRef = this.modalService.show(ModalConfirmationComponent,
  {class: 'modal-dialog-centered modal-lg', initialState});

到目前为止,我还没有看到官方文档中对此进行了记录。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-06
    • 1970-01-01
    • 2011-11-15
    • 1970-01-01
    • 2018-09-12
    • 2018-04-10
    • 2020-10-14
    • 2018-07-19
    相关资源
    最近更新 更多