Material-design-lite: Layout spacer is not working in drawer

Created on 23 Aug 2015  路  7Comments  路  Source: google/material-design-lite

Adding <div class="mdl-layout-spacer"></div> in drawer navigation doesn't work.
Here is the Codepen http://codepen.io/kushdilip/pen/eNqYpO

I have tried layout spacer with material 1.0.0, 1.0.1, 1.0.2 and 1.0.3 as well. none of them worked.

Most helpful comment

Instead of using an inline style, just use the spacer class on the nav.

<!-- No header, and the drawer stays open on larger screens (fixed drawer). -->
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-drawer">
  <div class="mdl-layout__drawer">
    <span class="mdl-layout-title">MDL 1.0.4</span>
    <nav class="mdl-navigation mdl-layout-spacer">
      <a class="mdl-navigation__link" href="">Link</a>
      <div class="mdl-layout-spacer"></div>
      <a class="mdl-navigation__link" href="">Logo</a>
    </nav>
  </div>
  <main class="mdl-layout__content">
    <div class="page-content"><!-- Your content goes here --></div>
  </main>
</div>

All 7 comments

you can use mdl-cell--hide-desktop if the intention is to hide the mdl-layout__drawer.

that's what you want to do?

It works in this template: http://www.getmdl.io/templates/dashboard/index.html

Probably because they redefine the style on mdl-navigation__link as flexbox. Might be a good idea to set that by default then?

@tleunen I think that was already suggested templates for some other issue

@Bound3R I don't want to hide the drawer. My intention is to get exactly what is achieved in http://www.getmdl.io/templates/dashboard/index.html

To produce the same effect as the template, you can add flex-grow: 1; to the mdl-navigation class as show below

<!-- No header, and the drawer stays open on larger screens (fixed drawer). -->
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-drawer">
  <div class="mdl-layout__drawer">
    <span class="mdl-layout-title">MDL 1.0.4</span>
    <nav class="mdl-navigation" style="flex-grow: 1;">
      <a class="mdl-navigation__link" href="">Link</a>
      <div class="mdl-layout-spacer"></div>
      <a class="mdl-navigation__link" href="">Logo</a>
    </nav>
  </div>
  <main class="mdl-layout__content">
    <div class="page-content"><!-- Your content goes here --></div>
  </main>
</div>

Instead of using an inline style, just use the spacer class on the nav.

<!-- No header, and the drawer stays open on larger screens (fixed drawer). -->
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-drawer">
  <div class="mdl-layout__drawer">
    <span class="mdl-layout-title">MDL 1.0.4</span>
    <nav class="mdl-navigation mdl-layout-spacer">
      <a class="mdl-navigation__link" href="">Link</a>
      <div class="mdl-layout-spacer"></div>
      <a class="mdl-navigation__link" href="">Logo</a>
    </nav>
  </div>
  <main class="mdl-layout__content">
    <div class="page-content"><!-- Your content goes here --></div>
  </main>
</div>

@Garbee Thanks for the brilliant solution. Should I close this issue ?
@kingstenbanh thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DeepSwami picture DeepSwami  路  3Comments

samuelcarreira picture samuelcarreira  路  4Comments

ktodyruik picture ktodyruik  路  5Comments

dryror picture dryror  路  5Comments

lgg picture lgg  路  3Comments