[英]How to make ngx-bootstrap modal resize horizontally?
I have a working ngx-bootstrap modal created in angular 5. I wanted to allow user to resize the width of the modal after it is displayed. 我在angular 5中创建了一个有效的ngx-bootstrap模态。我想允许用户在显示模态后调整其宽度。 does any css properties must be included.?
是否必须包含任何CSS属性?
config = { backdrop: true, ignoreBackdropClick: true }; modalRef: BsModalRef; openModal(template: TemplateRef<any>) { this.modalRef = this.modalService.show(template, this.config); }
<ng-template #template style="width:35%;margin-left:105px;margin-top:-4px;background-color: #ffffdd"> <div style="padding-right:-18px"> <button type="button" style="width:25px" class="close pull-right" aria-label="Close" (click)="modalRef.hide()"> <span style="font-size:2.5rem;margin-left:-1%" aria-hidden="true">×</span> </button> </div> <br> <div style="text-align: left;padding-left: 5px;background-color: #ffffdd"> <pre> {{data}}</pre> </div> </ng-template> <button type="button" class="btn btn-primary" (click)="openModal(template)">Create template modal</button>
Wanted to allow user to drag and increase the width of ngx modal 希望允许用户拖动并增加ngx模态的宽度
The size of the Bootstrap Modal depends on two classes: 'modal-lg'
is for Large Modal and 'modal-sm'
is for small modal. Bootstrap Modal的大小取决于两类:
'modal-lg'
用于大型Modal, 'modal-sm'
用于小型Modal。
You can use [ngClass]
to toggle these classes like this: 您可以使用
[ngClass]
这样切换这些类:
<div class="modal-dialog" [ngClass]="bigSize ? 'modal-lg' : 'modal-sm'">
And toggle the bigSize
boolean property on a user event, click of a button for eg: 并在用户事件上切换
bigSize
布尔属性,例如单击按钮:
<button (click)="bigSize = !bigSize">Toggle Size</button>
Here's a Working Sample StackBlitz for your ref.
这是供您参考的工作样本StackBlitz 。
In CSS file need to add below lines 在CSS文件中需要添加以下几行
::ng-deep .modal-content{
width: 800px;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.