代码之家  ›  专栏  ›  技术社区  ›  core114

角材料固定侧杆收割台不是固定的

  •  1
  • core114  · 技术社区  · 7 年前

    Angular material Fixed side nav ,但我在项目中遇到了一些冲突,我的问题是侧栏标题未修复,我添加了内容详细信息并滚动内容,然后标题被隐藏,

    Stack blitz code here

    如何解决此问题

    谢谢

    sidenav-fixed-example.html

     <mat-toolbar class="example-header">Header</mat-toolbar>
    
      <mat-sidenav-container class="example-container">
        <mat-sidenav #sidenav mode="side" opened class="example-sidenav">
        <mat-nav-list>
          <!-- Sidebar -->
          <ul class="sidebar navbar-nav" >
            <div class=" fixed-search " >
              <div class="sidebar-date-and-time">
    
    
          <span class="side-mnu" routerLink='/home'>
            <div class="d-flex flex-row bd-highlight mb-3">
             <div class="p-2 bd-highlight"><i class="fas fa-home"></i></div>
               <div class="p-2 bd-highlight txt-sm">Home</div>
                  </div>
                     </span>
    
    
                <span class="side-mnu-active"  routerLink='/categories'>
            <div class="d-flex flex-row bd-highlight mb-3">
             <div class="p-2 bd-highlight"><i class="fas fa-clipboard-list"></i></div>
               <div class="p-2 bd-highlight txt-sm">Categories</div>
                  </div>
                     </span>
    
    
    
                <span class="side-mnu" routerLink='/customerdetails'>
            <div class="d-flex flex-row bd-highlight mb-3">
             <div class="p-2 bd-highlight"><i class="fas fa-users"></i></div>
               <div class="p-2 bd-highlight txt-sm ">Customers</div>
                  </div>
                     </span>
    
    
                <span class="side-mnu" routerLink='/orderdetails'>
            <div class="d-flex flex-row bd-highlight mb-3">
             <div class="p-2 bd-highlight"><i class="fas fa-shopping-bag"></i></div>
               <div class="p-2 bd-highlight txt-sm">Orders</div>
                  </div>
                     </span>
    
    
    
    
                <span class="side-mnu">
            <div class="d-flex flex-row bd-highlight mb-3">
             <div class="p-2 bd-highlight"><i class="fas fa-clipboard-check"></i></div>
               <div class="p-2 bd-highlight txt-sm">Sales Items</div>
                  </div>
                     </span>
    
    
    
    
                <span class="side-mnu">
            <div class="d-flex flex-row bd-highlight mb-3">
             <div class="p-2 bd-highlight"><i class="fas fa-bullhorn"></i></div>
               <div class="p-2 bd-highlight txt-sm">Announcements</div>
                  </div>
                     </span>
    
              </div>
    
    
            </div>
            <!--side bar-->
    
          </ul>
    
        </mat-nav-list>
        </mat-sidenav>
    
        <mat-sidenav-content >
    
         Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
    Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.
        </mat-sidenav-content>
      </mat-sidenav-container>
    
      <mat-toolbar class="example-footer">Footer</mat-toolbar>
    

    .example-container {
      position: absolute;
      top: 60px;
      bottom: 60px; height: 100%;
      left: 0;
      right: 0;
    }
    
    .example-sidenav {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 200px;
      background: rgba(255, 0, 0, 0.5);
    }
    
    .example-header {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
    }
    
    .example-footer {
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
    }
    
    3 回复  |  直到 7 年前
        1
  •  2
  •   Sanket Tikam    7 年前

    正如@Deepu在其回答中所述,添加 z-index:2 header 仍然在顶部 sidenav .

    但是,如果链接在 超出了它所能容纳的范围。因此,计算 是一个更好的选择,同时设置 z-index .

    height: calc(100% -120px); .example-container 班我从100%高度中减去120px,因为这是页眉高度和页脚高度的总和。

    这是正在进行的闪电战 demo 和 code 链接

        2
  •  1
  •   dilusha_dasanayaka    7 年前

    您必须设置FixedViewport属性。

    [fixedInViewport]="true"

    <mat-sidenav #sidenav mode="side" opened class="example-sidenav"  [fixedInViewport]="true" >
    
        3
  •  1
  •   Deepu Reghunath    7 年前

    z-index 价值为 2 上课 example-header

    .example-header {
     position: fixed;
     top: 0;
     left: 0;
     right: 0;
     z-index: 2;
    }
    

    stackblitz link