菜单项不会下推旁边的菜单

Menu item does not push down the menu next to it

我有一个下拉菜单。正如下面的屏幕截图所示,我的分析下拉菜单之一没有下推列表中的下一个。我确定我有 css 问题,但我没有找到解决方案。我知道我的描述不是最好的或详细的,但我只是不知道发生了什么以及有什么问题。如果需要其他信息或文件,请告诉我,我会添加请求的内容。

<mat-nav-list>
<!--    overflow hidden-->
<div *ngFor="let item of menuItems" style="overflow: visible;">
    <!-- if it's not desabled and not a separator and not icon -->
    <mat-list-item
        sideNavAccordion
        class="sidebar-list-item"
        role="listitem"
        *ngIf="!item.disabled && item.type !== 'separator' && item.type !== 'icon'"
        [ngClass]="{'has-submenu': item.type === 'dropDown'}"
        routerLinkActive="open">
        <mat-icon *ngIf="item.icon === 'dvr'" style="width: 30px; height: 30px;
                    position: absolute;
                    left: 89%;
                    top: 0; background: transparent !important;" svgIcon="insignia" matTooltip="PRO"></mat-icon>
        <a routerLink="/{{item.state}}" *ngIf="item.type === 'link'">
    <span
        class="menu-item-tooltip"
        matTooltip="{{item.tooltip | translate}}"
        matTooltipPosition="right"></span>
            <mat-icon>{{item.icon}}</mat-icon>
            <span>{{item.name | translate}}</span>
        </a>
        <a *ngIf="item.type === 'dropDown'">
    <span
        class="menu-item-tooltip"
        [matTooltip]="item.tooltip"
        matTooltipPosition="above"></span>
            <mat-icon>{{item.icon}}</mat-icon>
            <span>{{item.name | translate}}</span>
            <span fxFlex></span>
            <mat-icon class="menu-caret">arrow_drop_down</mat-icon>
        </a>
        <a [href]="item.state" *ngIf="item.type === 'extLink'" target="_blank">
    <span
        class="menu-item-tooltip"
        [matTooltip]="item.tooltip"
        matTooltipPosition="right"></span>
            <mat-icon>{{item.icon}}</mat-icon>
            <span>{{item.name | translate}}</span>
        </a>
        <mat-nav-list class="sub-menu" role="list" *ngIf="item.type === 'dropDown'">
            <mat-list-item
                routerLinkActive="selected"
                *ngFor="let subItem of item.sub">
                <a routerLink="{{item.state ? '/'+item.state : ''}}/{{subItem.state}}">{{subItem.name |
                    translate}}</a>
            </mat-list-item>
        </mat-nav-list>
    </mat-list-item>
    <mat-divider></mat-divider>
    <!-- If item type is separator -->
    <div class="mt-1 mb-1" *ngIf="!item.disabled && item.type === 'separator'">
        <mat-divider></mat-divider>
        <span class="nav-section-title text-muted" *ngIf="!!item.name">{{item.name | translate}}</span>
    </div>
</div>

.sidebar-panel.mat-sidenav .mat-nav-list .sidebar-list-item .mat-list-item-content {
    font-size: .875rem !important;
    display: block;
    overflow: hidden;
    height: auto;
    padding: 0;
    width: 100%;
    -webkit-transition: max-height .3s cubic-bezier(.35, 0, .25, 1);
    transition: max-height .3s cubic-bezier(.35, 0, .25, 1);
}
.mat-nav-list .mat-list-item-content.mat-list-item-focus, .mat-nav-list .mat-list-item-content:hover {
    background: transparent;
}
.sidebar-list-item.open > .mat-list-item-content {
    background: rgba(0, 0, 0, .03);
}
.sidebar-panel .mat-nav-list a {
    position: relative;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    -ms-flex-direction: row;
    flex-direction: row;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    height: 48px;
    padding: 0 16px 0 0;
    z-index: 99;
}
.sidebar-panel.mat-sidenav .sidebar-list-item mat-icon:not(.menu-caret) {
    text-align: center;
    margin-right: 3px;
    height: 48px;
    width: 48px;
    line-height: 48px;
    border-left: 3px solid;
    border-color: transparent;
}
.sidebar-panel.mat-sidenav .sidebar-list-item mat-icon.menu-caret {
    float: right;
    -webkit-transform: rotate(0deg);
    transform: rotate(0deg);
    -webkit-transition: all .3s cubic-bezier(.35,0,.25,1);
    transition: all .3s cubic-bezier(.35,0,.25,1);
}
.sidebar-panel.mat-sidenav .sidebar-list-item.open mat-icon.menu-caret {
    float: right;
    -webkit-transform: rotate(180deg);
    transform: rotate(180deg);
}
.sidebar-panel.mat-sidenav .mat-list-item-content > a {
    width: 100%;
    display: flex;
    box-sizing: border-box;
    flex-direction: row;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
}
.sidebar-panel.mat-sidenav .sidebar-list-item {
    max-height: 48px;
    overflow: hidden;
    -webkit-transition: all .3s cubic-bezier(.35,0,.25,1);
    transition: all .3s cubic-bezier(.35,0,.25,1);
}
.sidebar-panel.mat-sidenav .sidebar-list-item.open {
    max-height: 1000px;
    overflow: visible;
}
.sidebar-panel.mat-sidenav .sidebar-list-item.open > .mat-list-item-content > .sub-menu {
    max-height: 1000px;
}
.sidebar-panel.mat-sidenav .sidebar-list-item .sub-menu {
    padding: 0;
    -webkit-transition: max-height .3s cubic-bezier(.35,0,.25,1);
    transition: max-height .3s cubic-bezier(.35,0,.25,1);
    border-left: 3px solid transparent;
}
.sidebar-panel.mat-sidenav .sidebar-list-item .sub-menu .mat-list-item {
    -webkit-transition: height .3s cubic-bezier(.35,0,.25,1);
    transition: height .3s cubic-bezier(.35,0,.25,1);
}
.sidebar-panel.mat-sidenav .sidebar-list-item .sub-menu .mat-list-item.selected {
    background: rgba(0, 0, 0, .05);
}

.sidebar-panel.mat-sidenav .sub-menu a {
    padding-left: 54px;
}
.app-side-nav-container .mat-sidenav-content {
    padding: 0;
}

找到问题了。解决方法:

  • menuItems div 必须溢出:隐藏
  • 元素必须显示:inline-block