简体   繁体   English

mat-sidenav-container 的 CSS 在 safari 上损坏

[英]CSS of mat-sidenav-container broken on safari

I am using a mat-sidenav-container.我正在使用 mat-sidenav-container。 My codes run properly on İE, Chrome, Firefox.我的代码在 İE、Chrome、Firefox 上运行正常。 but broken only on safari;但仅在 safari 上损坏; app-header must be on top and fixed.but it doesn't seem on top. app-header 必须在顶部并固定。但它似乎不在顶部。 I think this error is about the position:absolute.我认为这个错误是关于 position:absolute。 but I can't solve但我无法解决

app.commponent;应用程序组件;

<mat-sidenav-container [ngClass]="{'container':(!currentUrl && userAuth)}">
  <mat-sidenav [ngClass]="{'sidenavUser':(isExpanded && !currentUrl && userAuth),
                            'sidenavExpanded':(!currentUrl && userAuth && !isExpanded && !mobileQuery.matches)}"
   #sidenav role="navigation"
   [mode]="mobileQuery.matches ? 'over' : 'side'" 
   [(opened)]="!mobileQuery.matches && userAuth "
   fullscreen>

    <app-sidenav [mobileQuery]="mobileQuery.matches"  [userAuth]="userAuth$" (closeSidenav)="sidenavClose($event)"></app-sidenav>
  </mat-sidenav>

  <mat-sidenav-content>
    <app-header [ngClass]="{'header':(!currentUrl && userAuth)}"  [userAuth]="userAuth$"
      (sidenavToggle)="sidenav.toggle()"></app-header>

    <main>
      <router-outlet></router-outlet>
    </main>
  </mat-sidenav-content>
</mat-sidenav-container>

app.component.css app.component.css

mat-sidenav{
  width: 250px;
  z-index: 1000;
}

  .sidenavUser {
    width: 250px;
    position: fixed;
    top:80px;
    bottom: 0px;
    z-index: 1000;
  }
  .sidenavExpanded{
    width: auto;
    position: fixed;
    top:80px;
    bottom: 0px;
    z-index: 1000;
    }

  mat-sidenav-content{

      height: 100%;
  }
  mat-sidenav-container{
  background-color: rgb(246, 246, 248);
  width: 100%;
  margin: 0;
  min-height: 1000px;
  }


  .container {
    position: absolute;
    top: 80px;
    left: 0;
    right: 0;
  }
  .header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color:transparent;

  }

  .menuButton{
    position: absolute;
    top: 80px;
    left: 0;
    right: 0;

  }

.container and header position absolute not work. .container 和 header position 绝对不起作用。 my toolbar is unvisible first.我的工具栏首先是不可见的。

toolbar.css工具栏.css

.toolbarTop{
  background-color:transparent;
  position: fixed;
  top: 0; /* Sets the sticky toolbar to be on top */
  height: 80px;
  z-index: 2;
  margin: 0;

} 
.toolbarOffsetY{
  background-color:rgba(0, 0, 0, 0.5);
  position: fixed;
  top: 0; /* Sets the sticky toolbar to be on top */
  height: 80px;
  z-index: 1000;
  margin: 0;

}
.toolbarUser{
  background-color:rgba(0, 0, 0, 0.5);
  position: -webkit-sticky;
  position: sticky;
   /* For macOS/iOS Safari */
  top: 0; /* Sets the sticky toolbar to be on top */
  height: 80px;
  z-index: 1000;
  margin: 0;

}

I could solve this problem.我可以解决这个问题。 I changed position of app-header.我更改了应用程序头的 position。 because when app-header was inside mat-sidenav-container, the safare gave bugged.因为当 app-header 在 mat-sidenav-container 中时,安全性出现了问题。 this my new code;这是我的新代码;

<div fxFlex>
**<app-header  [userAuth]="userAuth$"
      (sidenavToggle)="sidenav.toggle()"></app-header>**
<mat-sidenav-container autosize>
  <mat-sidenav [ngClass]="{'sidenavUser':(isExpanded && !currentUrl && userAuth),
                            'sidenavnotExpanded':(!currentUrl && userAuth && !isExpanded)}"
   #sidenav role="navigation"
   [mode]="mobileQuery.matches || currentUrl  ? 'over' : 'side'" 
   [(opened)]="!mobileQuery.matches && userAuth "
   fullscreen>

    <app-sidenav 
    [mobileQuery]="mobileQuery.matches"
    [currentUrl]="currentUrl" 
    [userAuth]="userAuth$"
    (closeSidenav)="sidenavClose($event)"></app-sidenav>
  </mat-sidenav>

  <mat-sidenav-content>
    <main>
      <router-outlet></router-outlet>
    </main>
  </mat-sidenav-content>
</mat-sidenav-container>
</div> 

and added css并添加了 css

mat-sidenav-container{
  position: unset;
}

it worked.有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM