[英]Mat-autocomplete and mat-select overlapping my header
<mat-autcomplete>
and <mat-select>
are overlaying my header. <mat-autcomplete>
和<mat-select>
覆盖了我的标题。 I have a sticky header and if I'm opening mat-autocomplete
or mat-select
and I'm scrolling, the list is overlaying the header.我有一个粘性标题,如果我打开
mat-autocomplete
或mat-select
并且我正在滚动,列表会覆盖标题。 I saw that the content is in a div cdk-overlay-container.我看到内容在一个div cdk-overlay-container中。 I've tried to use a bigger
z-index
for header but not works.我尝试为标头使用更大的
z-index
但不起作用。
Here it is: below I just want to make the slide toggle to not be covered by the panel.在这里:下面我只想让滑动切换不被面板覆盖。 So I applied a class to its
div
container ( my-class
).所以我将一个类应用于它的
div
容器 ( my-class
)。
.my-class {
position: relative;
z-index: 2000;
background-color: blue;
color: white;
}
z-index
must be higher than 1000 ( @angular/cdk/overlay
's default z-index). z-index
必须高于 1000( @angular/cdk/overlay
的默认 z-index)。
position: relative
is important here, as, per css docs (w3schools): position: relative
在这里很重要,因为,根据 css 文档 (w3schools):
z-index
only works on positioned elements (position: absolute, position: relative, position: fixed, or position: sticky).z-index
仅适用于定位元素(position: absolute, position: relative, position: fixed, or position: sticky)。
<form class="example-form">
<mat-form-field class="example-full-width">
<input matInput placeholder="State" aria-label="State" [matAutocomplete]="auto" [formControl]="stateCtrl">
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let state of filteredStates | async" [value]="state.name">
<img class="example-option-img" aria-hidden [src]="state.flag" height="25">
<span>{{state.name}}</span> |
<small>Population: {{state.population}}</small>
</mat-option>
</mat-autocomplete>
</mat-form-field>
<br>
<div class="my-class">
<mat-slide-toggle
[checked]="stateCtrl.disabled"
(change)="stateCtrl.disabled ? stateCtrl.enable() : stateCtrl.disable()">
Disable Input?
</mat-slide-toggle>
</div>
</form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.