irpas技术客

ant组件中modal的居中显示_木木芳草_antd modal 居中

大大的周 7948

注:该组件本身自带的居中显示:当缩小窗口,其宽度比modal小的时候会掉下去,上面留有一段空白,是因为before的高度问题引起 列:

this.modalService.create({ nzContent: ModalTellDetailComponent, nzWrapClassName: 'centerModal', nzFooter: null, nzMaskClosable: false, nzClosable: false, nzCloseIcon: null, nzAutofocus: null });

注:其中nzAutofocus不设置时,会导致出现父页面的滚动条。 完美解决办法:兼容IE

.centerModal { display: flex; text-align: center; .ant-modal { top:auto; display: inline-block; align-self: center; max-height: calc(100vh - 30px); margin: auto; text-align: left; vertical-align: middle; } }

注:如果top有值会导致在火狐浏览器出现滚动条。


1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,会注明原创字样,如未注明都非原创,如有侵权请联系删除!;3.作者投稿可能会经我们编辑修改或补充;4.本站不提供任何储存功能只提供收集或者投稿人的网盘链接。

标签: #Antd #modal #居中