[英]Way to add or apply multiple classes for ngx-bootstrap modal
I want to show an ngx-bootstrap modal centered and in a large format.我想以大格式显示一个居中的 ngx-bootstrap 模态。
There is two classes for this: modal-dialog-centered
and modal-lg
but I don't see any way to apply these classes at the same time.有两个类:
modal-dialog-centered
和modal-lg
但我看不出有任何方法可以同时应用这些类。
When looking to the ngx-bootstrap source code here: modal-options.class.ts在此处查看ngx-bootstrap源代码时: modal-options.class.ts
There is an optional class property
defined as class?: string;
有一个可选的
class property
定义为class?: string;
. . but it's not defined as an array of classes that we can apply.
但它没有定义为我们可以应用的类数组。
so now I can show the modal centered by using:所以现在我可以使用以下方法显示模态居中:
this.bsModalRef = this.modalService.show(ConfirmationComponent,
{class: 'modal-dialog-centered', initialState});
or a large modal but not centered:或大模态但不居中:
this.bsModalRef = this.modalService.show(ModalConfirmationComponent,
{class: 'modal-lg', initialState});
I tried to add this to the beginning template of the modal:我尝试将其添加到模态的开始模板中:
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
...
But no luck as well, the class modal-lg
don't want to work但也没有运气,类
modal-lg
不想工作
Anyone have an idea how to get this to work ?任何人都知道如何让它发挥作用?
Update更新
This CSS looks to give some result but not behaving completely well:这个 CSS 看起来给出了一些结果,但表现不佳:
::ng-deep .modal.show .modal-dialog {
-webkit-transform: translate(50%, 50%);
transform: translate(0%, 50%);
}
The suggestion provided by @MikeOne works perfectly. @MikeOne 提供的建议非常有效。
So adding space separated classes will provide the ability to apply more than one class to the modal.因此,添加空格分隔的类将提供将多个类应用于模态的能力。
we can show the modal perfectly centered and large one with this code:我们可以使用以下代码显示模态完全居中且较大的模态:
this.bsModalRef = this.modalService.show(ModalConfirmationComponent,
{class: 'modal-dialog-centered modal-lg', initialState});
So far, I don't see where this is documented in the official documentation.到目前为止,我没有看到官方文档中记录了这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.