【问题标题】:want to apper menu icon button in top right. in Material Design Lite想要在右上角出现菜单图标按钮。在材料设计精简版
【发布时间】:2015-11-22 16:40:41
【问题描述】:

我想移动右上角的菜单图标按钮。但它出现在标题下。 我应该添加什么样的属性或属性?

    <!-- Simple header with fixed tabs. -->
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-header
            mdl-layout--fixed-tabs">
  <header class="mdl-layout__header">
    <div class="mdl-layout__header-row">
      <!-- Title -->
      <span class="mdl-layout-title">Title</span>
    </div>
    <!-- Right aligned menu below button -->

<button id="demo-menu-lower-right"
        class="mdl-button mdl-js-button mdl-button--icon">
  <i class="material-icons">more_vert</i>
</button>

<ul class="mdl-menu mdl-menu--bottom-right mdl-js-menu mdl-js-ripple-effect"
    for="demo-menu-lower-right">
  <li class="mdl-menu__item">Some Action</li>
  <li class="mdl-menu__item">Another Action</li>
  <li disabled class="mdl-menu__item">Disabled Action</li>
  <li class="mdl-menu__item">Yet Another Action</li>
</ul>
    <!-- Tabs -->
    <div class="mdl-layout__tab-bar mdl-js-ripple-effect">
      <a href="#fixed-tab-1" class="mdl-layout__tab is-active">Tab 1</a>
      <a href="#fixed-tab-2" class="mdl-layout__tab">Tab 2</a>
      <a href="#fixed-tab-3" class="mdl-layout__tab">Tab 3</a>
      <a href="#fixed-tab-4" class="mdl-layout__tab">Tab 4</a>
    </div>
  </header>

here is a image url

【问题讨论】:

  • 您能提供您的css 代码吗?
  • 您可以使用CSSposition: absolute 属性并将您的菜单图标按钮定位在右上角。
  • @Amitsingh 没有与此相关的 css 代码。

标签: html css menu icons material-design-lite


【解决方案1】:

要使菜单出现在右侧,您需要在mdl-layout__header-row 元素内添加以下div,然后在头部右侧添加您想要的任何元素。有关详细信息,请参阅 Layout 上的 Material Design Lite。

<div class="mdl-layout mdl-js-layout">
  <header class="mdl-layout__header mdl-layout__header--transparent">
    <div class="mdl-layout__header-row">
      <!-- Title -->
      <span class="mdl-layout-title">Title</span>

      <!-- Add spacer, to align navigation to the right -->
      <div class="mdl-layout-spacer"></div>

      <!-- Navigation -->
      <nav class="mdl-navigation">
        <a class="mdl-navigation__link" href="">Link</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>

      <!-- Right Menu -->
      <button id="demo-menu-lower-right"
              class="mdl-button mdl-js-button mdl-button--icon">
        <i class="material-icons">more_vert</i>
      </button>

      <ul class="mdl-menu mdl-menu--bottom-right mdl-js-menu mdl-js-ripple-effect"
          for="demo-menu-lower-right">
        <li class="mdl-menu__item">Some Action</li>
        <li class="mdl-menu__item">Another Action</li>
        <li disabled class="mdl-menu__item">Disabled Action</li>
        <li class="mdl-menu__item">Yet Another Action</li>
      </ul><!--/Right Menu -->
    </div>
  </header>
  <div class="mdl-layout__drawer">
    <span class="mdl-layout-title">Title</span>
    <nav class="mdl-navigation">
      <a class="mdl-navigation__link" href="">Link</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>
  <main class="mdl-layout__content">
  </main>
</div>

另外,如果你想改变Menu的位置,你可以把mdl-menu--bottom-right改成你喜欢的方向。请参考页面底部的 MDL Menu 规范。

【讨论】:

    【解决方案2】:
      <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header
            mdl-layout--fixed-tabs">
           <header class="mdl-layout__header">
              <div class="mdl-layout__header-row">
                  <div class="row" style="margin:0">
                     <!-- Title -->
                      <span class="mdl-layout-title left">Title</span>
    
                     <!-- Right aligned menu below button -->
    
                     <button id="demo-menu-lower-right" class="mdl-button mdl-js-button mdl-button--icon right">
                       <i class="material-icons">more_vert</i>
                     </button>
                   </div>
               </div>
               <ul class="mdl-menu mdl-menu--bottom-right mdl-js-menu mdl-js-ripple-effect" for="demo-menu-lower-right">
                  <li class="mdl-menu__item">Some Action</li>
                     <li class="mdl-menu__item">Another Action</li>
                   <li disabled class="mdl-menu__item">Disabled Action</li>
                  <li class="mdl-menu__item">Yet Another Action</li>
               </ul>
                <!-- Tabs -->
                 <div class="mdl-layout__tab-bar mdl-js-ripple-effect">
                  <a href="#fixed-tab-1" class="mdl-layout__tab is-active">Tab 1</a>
                  <a href="#fixed-tab-2" class="mdl-layout__tab">Tab 2</a>
                   <a href="#fixed-tab-3" class="mdl-layout__tab">Tab 3</a>
                  <a href="#fixed-tab-4" class="mdl-layout__tab">Tab 4</a>
                  </div>
                </header>
    

    我已经编辑了您给定的代码。希望对您有所帮助

    【讨论】:

    猜你喜欢
    • 2016-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-18
    • 2020-12-25
    • 2017-12-22
    • 2017-05-01
    • 1970-01-01
    相关资源
    最近更新 更多