Different mdl-layout__drawer for large screen and small screen in MDL

社会主义新天地 提交于 2019-12-11 02:49:31

问题


I, am trying to create two different mdl-layout__drawer for small screen and large screen. As per the below code only on small screen the mdl-layout__drawer is showing it is not showing on large screen.

<div class="mdl-layout__drawer mdl-layout--large-screen-only">
        <span class="mdl-layout-title"><img src="~/images/transfeteBirdLogo.png" width="80" height="80" /></span>
        <nav class="mdl-navigation">
            <a class="mdl-navigation__link" href="">Link21</a>
            <a class="mdl-navigation__link" href="">Link</a>
            <a class="mdl-navigation__link" href="">Link</a>
            <a class="mdl-navigation__link" href="">Link</a>
        </nav>
    </div>

    <div class="mdl-layout__drawer mdl-layout--small-screen-only">
        <span class="mdl-layout-title"><img src="~/images/transfeteBirdLogo.png" width="80" height="80" /></span>
        <nav class="mdl-navigation">
            <a class="mdl-navigation__link" href="">Link11</a>
            <a class="mdl-navigation__link" href="">Link</a>
            <a class="mdl-navigation__link" href="">Link</a>
            <a class="mdl-navigation__link" href="">Link</a>
        </nav>
    </div>

Can anyone tell me what is wrong in the code. How can I solve this issue.


回答1:


Your whole code should be wrapped in a div containing mdl-layout, mdl-js-layout and mdl-layout--fixed-drawer classes. The last one is responsible for showing the navigation menu in large screens. Pen here.

<div class="mdl-layout mdl-js-layout mdl-layout--fixed-drawer">
  <div class="mdl-layout__drawer mdl-layout--large-screen-only">
    <span class="mdl-layout-title"><img src="~/images/transfeteBirdLogo.png" width="80" height="80" /></span>
    <nav class="mdl-navigation">
      <a class="mdl-navigation__link" href="">Link21</a>
      <a class="mdl-navigation__link" href="">Link</a>
      <a class="mdl-navigation__link" href="">Link</a>
      <a class="mdl-navigation__link" href="">Link</a>
    </nav>
  </div>

  <div class="mdl-layout__drawer mdl-layout--small-screen-only">
    <span class="mdl-layout-title"><img src="~/images/transfeteBirdLogo.png" width="80" height="80" /></span>
    <nav class="mdl-navigation">
      <a class="mdl-navigation__link" href="">Link11</a>
      <a class="mdl-navigation__link" href="">Link</a>
      <a class="mdl-navigation__link" href="">Link</a>
      <a class="mdl-navigation__link" href="">Link</a>
    </nav>
  </div>
</div>


来源:https://stackoverflow.com/questions/45754638/different-mdl-layout-drawer-for-large-screen-and-small-screen-in-mdl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!