模态垂直位置中心

时间:2018-01-16 11:32:02

标签: css angular

1.如何将模态放在中心?

2.使用Angular 2/4和html5,JS和css!

<ng-template #content let-c="close">
                <div class="modal-header">
                    <h4 class="modal-title">Deseja excluir definitivamente?</h4>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" title="Confirmar Ação" (click)="c('Close click')" (click)="deleteUser(user)">Confirmar</button>
                    <button type="button" class="btn btn-secondary" title="Cancelar Ação" (click)="c('Close click')">Cancelar</button>
                </div>
            </ng-template>

2 个答案:

答案 0 :(得分:0)

<ng-template #content let-c="close">
            <div class="modal-header">
                <h4 class="modal-title">Deseja excluir definitivamente?</h4>
            </div>
            <!--add this in start here--><div class="modal-body">
    <p>Some text in the modal.</p><!--end here-->
  </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" title="Confirmar Ação" (click)="c('Close click')" (click)="deleteUser(user)">Confirmar</button>
                <button type="button" class="btn btn-secondary" title="Cancelar Ação" (click)="c('Close click')">Cancelar</button>
            </div>
        </ng-template>

答案 1 :(得分:0)

根据您的要求,您的模态应该是固定高度,因此根据您可以设置上边距和其他CSS。

您必须在模态体中渲染DOM / HTML后计算模态高度,然后再应用一些计算逻辑并从后端设置上边距。