[英]How to change the position of modals in ng-bootstrap
我无法弄清楚在任何地方显示模态的方式,但默认一种,以顶部为中心,对我来说,这是显示模态的最丑陋的地方。
有人可以帮忙吗?
首先,我想在中间的某个地方展示它。
我试图更改模态组件样式表中的 css,但没有成功。 而且我不想更改所有模态的样式。
您可以使用打开模态函数中的配置类将自己的自定义类添加到模态对话框
openModal(modal_id) {
this.modalService.open(modal_id, { windowClass: 'custom-class' });
}
以上结果产生以下 html 结构:
<div class="modal custom-class">
<div class="modal-dialog">
<div class="modal-content">
...
</div>
</div>
</div>
您的自定义 css 可以具有以下代码:
.custom-class {
position: relative;
top: 50%;
transform: translateY(-50%);
}
如果你想垂直居中,他们有一个centered
选项,你可以使用:
this.modalService.open(your_modal, { centered: true })
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.