简体   繁体   English

为 ngx-bootstrap modal 添加或应用多个类的方法

[英]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-centeredmodal-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.

相关问题 使用ngx-bootstrap modalService时添加自定义类的方法 - Way to add custom class when using ngx-bootstrap modalService 如何将 ngx-bootstrap 模式居中 - How to center an ngx-bootstrap modal 如何从父组件 CSS 将宽度应用于特定子 ngx-bootstrap 模态 - How to apply width to specific child ngx-bootstrap Modal from parent component CSS 如何使用modalService使用情况将自定义css添加到ngx-bootstrap模态(请参见下面的原因)? - How to add custom css to ngx-bootstrap modal with modalService useage(see reasons below)? 当模态高度为动态滚动时的 ngx-bootstrap 不会出现 - ngx-bootstrap when modal height is dynamic scroll is not coming Angular ngx-bootstrap - 如何制作大而宽的模态 - Angular ngx-bootstrap - how to make a big, wide modal 如何将自定义样式添加到 ngx-bootstrap/tooltip - How to add custom style to ngx-bootstrap/tooltip 如何将自定义css添加到ngx-bootstrap工具提示? - How to add custom css to ngx-bootstrap tooltip? 如何在 ngx-bootstrap 手风琴中添加折叠图标 - How to add a collapse icon in ngx-bootstrap Accordion 为什么这个输入类型=“checkbox”标签的html模式用于破坏ngx-bootstrap模式对话框 - Why is this html pattern of input type="checkbox" lable for breaking the ngx-bootstrap modal dialog
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM