我想以大格式显示一个居中的 ngx-bootstrap 模态。
有两类这个:modal-dialog-centered
和modal-lg
,但我没有看到任何方式在同一时间申请这些课程。
在此处查看ngx-bootstrap 源代码时: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%);
}
@MikeOne 提供的建议非常有效。
因此,添加空格分隔的类将提供将多个类应用于模态的能力。
我们可以使用以下代码显示模态完全居中且较大的模态:
this.bsModalRef = this.modalService.show(ModalConfirmationComponent,
{class: 'modal-dialog-centered modal-lg', initialState});
到目前为止,我没有看到官方文档中记录了这一点。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句