question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

md-sidenav-container > div.mat-drawer-content unwanted margin

See original GitHub issue

Bug, feature request, or proposal:

bug

What is the expected behavior?

There should be no unnecessary margin between the sidenav and the normal content.

What is the current behavior?

image

What are the steps to reproduce?

`<md-toolbar class="mat-elevation-z5" color="primary">

<button md-button routerLink="/">
  <md-icon>home</md-icon> 
      {{title}}</button>

  <!-- This fills the remaining space of the current row -->
  <span class="fill-remaining-space"></span>
  <div fxLayout="row" fxShow="false" fxShow.gt-sm>
      <button md-button routerLink="/products">Products</button>
      <button md-button routerLink="/dashboard">Dashboard</button>
  </div>
  <button md-button [md-menu-trigger-for]="menu" fxHide="false" fxHide.gt-sm>
   <md-icon>menu</md-icon>
  </button>
</md-toolbar>

<md-menu x-position=“before” #menu=“mdMenu”> <button md-menu-item routerLink="/products">Products</button> <button md-menu-item routerLink="/dashboard">Dashboard</button> </md-menu>

<md-sidenav-container class="myTestClass"> <md-toolbar color="primary" style="margin-left:0px"> <button *ngIf="isMobileView" md-icon-button (click)="sidenav.toggle()"> <md-icon class="md-24" >menu</md-icon> </button> </md-toolbar>
<!-- https://github.com/angular/material2/issues/1130 -->
<md-sidenav #sidenav class="app-sidenav"  mode="{{isMobileView?'over':'side'}}" opened="{{!isMobileView}}" disableClose="{{!isMobileView}}">
  <md-nav-list >
      <a md-list-item (click)="onLinkClick(sidenav)" >Majom Csimpánz Viziló</a>
      <a md-list-item href="page2.html">Page 2</a>
      <a md-list-item href="page3.html">Page 3</a>
  </md-nav-list>
</md-sidenav>
    
      <div class="app-content" style="padding-top:50px;"
      >
      <router-outlet></router-outlet>
    </div>

</md-sidenav-container>`

Please ignore the unnecessary codes.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

newest

Is there anything else we should know?

After I resize the window and the sidenav goes to mobile mode, and back -> the unwanted margin is gone…

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
sina-masoud-ansaricommented, Sep 11, 2017

I’m having the same issue, sidenav-width 250px, margin-left on Safari 399px.

Just fyi, a current work around in our project where the sidenav auto collapses for smaller screens:


.sidenav-container .mat-drawer-content {
  margin-left: $sidenav-width !important;

}

@media (max-width: $md-thresh-min) {

    .sidenav-container .mat-drawer-content {
      margin-left: 0 !important;
    }

}

2reactions
mmalerbacommented, Jan 27, 2018

Those of you experiencing issues, have you tried the autosize option? does it help?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular Incorrect Margin-Left Applied To Sidenav Content
I feel like it might have something to do with my isMobile() function and race condition, but not sure. In my app.component.html <div...
Read more >
Sidenav - Angular Material
The drawer component is designed to add side content to a small section of your app. This is accomplished using the <mat-drawer-container> ,...
Read more >
Mat-Sidenav-Content Content Is Being Overflowed Behind ...
And the space between the divs is created by adding padding in each we have used ... behavior? md-sidenav-container > div.mat-drawer-content unwanted margin...
Read more >
nix-component-library - UNPKG
</p>\n </div>\n <div mat-dialog-actions>\n <button mat-button ... host: {\n 'class': 'mat-drawer-content mat-sidenav-content',\n '[style.margin-left.px]': ...
Read more >
CSS in Depth
height or width of an element, you're setting the content size—any padding, ... margin collapsing outside its container typically produces an undesirable ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found