简体   繁体   English

将ng-href添加到按钮时,为什么md-menu与md-button不对齐?

[英]Why doesn't md-menu align with md-button when ng-href is added to the button?

Demo here: http://codepen.io/audiodude/pen/vLyNvw 此处的演示: http : //codepen.io/audiodude/pen/vLyNvw

The only difference between the top and the bottom is that the top uses an md-button with an ng-href attribute, which gets compiled by Angular Material to an a tag, while the bottom uses a plain md-button that gets compiled to a button tag. 顶部和底部之间的唯一区别是,顶部使用带有ng-href属性的md-button ,该属性由Angular Material编译为a标签,而底部使用普通的md-button将其编译为a button标签。 However, the .md-button class does seem to add all of the same styling to the anchor version of the button. 但是, .md-button类似乎确实将所有相同的样式添加到按钮的锚点版本中。

So why does the menu in the top example get seemingly pushed to a new line? 那么,为什么顶部示例中的菜单似乎被推到了新的一行?

<div ng-controller="AppCtrl" ng-cloak="" class="buttondemoBasicUsage" ng-app="MyApp">
  <md-content layout="column" layout-align="start center">
    <div layout="row" layout-align="center" layout-fill>
      <md-card flex-sm="95" flex-gt-md="70" layout="column">
        <div layout-sm="column" layout-gt-sm="row" flex>
          <div flex layout>
            <md-button ng-href="https://www.google.com" class="md-primary">
              <md-icon aria-label="launch">launch</md-icon> Link
            </md-button>
            <md-menu>
              <md-button aria-label="Open edit menu" class="md-icon-button" ng-click="$mdOpenMenu($event)">
                <md-icon md-menu-origin>arrow_drop_down</md-icon>
              </md-button>
              <md-menu-content width="5">
                <md-button>Menu Choice</md-button>
              </md-menu-content>
            </md-menu>
          </div>
          <span flex></span>
        </div>
      </md-card>
    </div>
  </md-content>

  <md-content layout="column" layout-align="start center">
    <div layout="row" layout-align="center" layout-fill>
      <md-card flex-sm="95" flex-gt-md="70" layout="column">
        <div layout-sm="column" layout-gt-sm="row" flex>
          <div flex>
            <md-button class="md-primary">
              <md-icon aria-label="launch">launch</md-icon> Link
            </md-button>
            <md-menu>
              <md-button aria-label="Open edit menu" class="md-icon-button" ng-click="$mdOpenMenu($event)">
                <md-icon md-menu-origin>arrow_drop_down</md-icon>
              </md-button>
              <md-menu-content width="5">
                <md-button>Menu Choice</md-button>
              </md-menu-content>
            </md-menu>
          </div>
          <span flex></span>
        </div>
      </md-card>
    </div>
  </md-content>
</div>

You just forgot to add "layout" attribute (by default it's row) in line 6. 您只是忘了在第6行中添加“布局”属性(默认情况下为该行)。

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

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