我有一个“编辑项目”按钮。单击“编辑”按钮时,会弹出一个窗口,我可以编辑字段。
当前,一切正常,但是布局看起来很丑,因为我必须向下滚动才能单击“保存/取消”按钮。 我想以无需向下滚动的方式调整弹出窗口。
我的编辑页面html是:
<div class="main-content">
<div class="container-fluid">
<div class="row">
<div class="card">
<div class="card-header">
<h5 class="title">Update Project</h5>
</div>
<div class="container">
<form class="mat-dialog-content" (ngSubmit)="submit" #formControl="ngForm">
<div class="form">
<mat-form-field color="accent">
<input matInput #input class="form-control" placeholder="Project Name" [(ngModel)]="data.projectName"
name="projectName" required>
<mat-error *ngIf="formControl.invalid">{{getErrorMessage()}}</mat-error>
</mat-form-field>
</div>
<!--Textarea for demo purposes-->
<div class="form">
<mat-form-field color="accent">
<textarea matInput #input class="form-control" placeholder="Description" [(ngModel)]="data.projectDescription"
name="projectDescription" required></textarea>
<mat-error *ngIf="formControl.invalid">{{getErrorMessage()}}</mat-error>
</mat-form-field>
</div>
<div mat-dialog-actions>
<button mat-button [type]="submit" [disabled]="!formControl.valid" [mat-dialog-close]="data" (click)="stopEdit()">Save</button>
<button mat-button (click)="onNoClick()" tabindex="-1">Cancel</button>
</div>
</form>
</div>
</div>
</div>
</div>
我的CSS是:
.container {
border-radius: 4px;
box-sizing: border-box;
overflow: auto;
outline: 0;
width: 500px;
height: 250px;
min-height: inherit;
max-height: inherit;
}
.form {
display: flex;
padding-top: 6px;
}
.mat-form-field {
font-size: 16px;
flex-grow: 1;
}
答案 0 :(得分:0)
使用overflow
属性并将其设置为要滚动的容器的hidden
。
答案 1 :(得分:0)
您必须将高度设置为.modal-body,并将其设置为溢出-y:隐藏。还要将.modal-dialog溢出值重置为初始值
.modal{
display: block !important; /* I added this to see the modal, you don't need this */
}
/* Important part */
.modal-dialog{
overflow-y: hidden !important
}
.modal-body{
height: 250px;
overflow-y: hidden;
}
答案 2 :(得分:0)
我在CSS中添加了视口的最小高度,并且可以正常工作。
.container {
border-radius: 4px;
box-sizing: border-box;
overflow-x: hidden;
overflow-y: hidden !important;
outline: 0;
width: 500px;
height: 250px;
min-height: inherit;
max-height: inherit;
.mat-dialog-content {
min-height: 35vh;
}
答案 3 :(得分:0)
示例
height: 200px;
or
height: 30%;
然后将这些添加到要滚动的根 div 的以下代码行
overflow-x: hidden;
overflow-y: hidden !important;