css - 使用 mat-expansion-panel 时增加下拉菜单的高度
问题描述
我将 ng-select 包裹在 mat-expansion-panel 中。我希望能够增加下拉列表的高度以超出 mat-expansion-panel 的高度,但我无法获得这种效果。我试图玩弄 z-index 但仍然无法正常工作。
我的代码:HTML
<mat-accordion>
<mat-expansion-panel class="shadow">
<mat-expansion-panel-header>
<mat-panel-title>
<b>Location</b>
</mat-panel-title>
</mat-expansion-panel-header>
<div class="location">
Country
<ng-select class="m-t-10" [(ngModel)]="selectedCountry">
<ng-option *ngFor="let country of countries" value="country.value">
<div class="famfamfam-flags {{country?.value.toLowerCase()}}"></div>
{{country?.label}}
</ng-option>
</ng-select>
</div>
<mat-divider></mat-divider>
<div class="location">
Province
<ng-select class="m-t-10" [(ngModel)]="selectedProvince">
<ng-option *ngFor="let province of provinces" value="country.value">
{{province?.label}}
</ng-option>
</ng-select>
</div>
<mat-divider></mat-divider>
<div class="location">
District
<ng-select class="m-t-10" [(ngModel)]="selectedDistrict">
<ng-option *ngFor="let district of districts" value="district.value">
{{district?.label}}
</ng-option>
</ng-select>
</div>
</mat-expansion-panel>
</mat-accordion>
import { Component,ViewEncapsulation} from "@angular/core";
import { CountryListService } from "./../country.service";
@Component({
selector: "app-location",
templateUrl: "./location.component.html",
styleUrls: ["./location.component.css"],
encapsulation: ViewEncapsulation.None,
providers: [CountryListService]
})
export class LocationComponent {
constructor(private countryList: CountryListService) {}
selectedCountry = "Select";
selectedProvince = "Select";
selectedDistrict = "Select";
countries = this.countryList.getCountries();
provinces = [{ label: "province1", value: "province1" }];
districts = [{ label: "Dist1", value: "District1" }];
}
国家服务
import {Injectable} from '@angular/core';
@Injectable()
export class CountryListService{
constructor(){}
getCountries(){
return CountryListService.COUNTRIES;
}
private static readonly COUNTRIES = [
{value: 'AF', label: 'Afghanistan'},
{value: 'AX', label: 'Åland Islands'},
{value: 'AL', label: 'Albania'},
{value: 'DZ', label: 'Algeria'},
{value: 'AS', label: 'American Samoa'},
{value: 'AD', label: 'Andorra'},
{value: 'AO', label: 'Angola'},
{value: 'AI', label: 'Anguilla'},
{value: 'AQ', label: 'Antarctica'},
{value: 'AG', label: 'Antigua and Barbuda'},
{value: 'AR', label: 'Argentina'}
];
}
解决方案
我不确定您要做什么,但我认为您正在寻找的是:
.ng-dropdown-panel {
position: relative !important;
}
在显示下拉列表选项时扩展 mat-expansion-panel 的高度。
推荐阅读
- python - 如何在不访问其子标签文本的情况下获取父标签的文本?
- react-native - 在 react-native 中是否有将文本、图像转换为 pdf 的库?
- sorting - 根据点差对并列分数进行排序/排名
- algorithm - 以下分配问题是否有有效的算法?
- python - 在 Python 中使用 Format 的 TypeError
- microsoft-edge - 如何为 Selenium Remote Webdriver 设置 Microsoft Edge 浏览器二进制文件
- powershell - 计算字符,不包括特定页面
- c++ - 比较枚举的值会导致编译器错误
- vba - 使用属性和子/函数有什么区别?
- python - 如何通过python3更改xml中元素属性的值