5

我在使用 Angular Flex 布局对齐项目时遇到问题。

下面的狙击手没有将<md-icon>标题的右侧对齐,这是我打算做的。

关于如何做到这一点的任何建议?

<div class="flex-item" fxFlex fxFlexAlign="end end">

<md-card style="background-color:white;">
   <md-card-header style="background-color:white;">
      <md-card-title>Swap Card</md-card-title>
      <div class="flex-item" fxFlex fxFlexAlign="end end">
         <md-icon>add_a_photo</md-icon>
         Icon
      </div>
   </md-card-header>
   <md-card-content>
   </md-card-content>
</md-card>
4

2 回答 2

9

您可以在两者之间添加一个灵活长度的空跨度:

<md-card>
  <md-card-header>
    <md-card-title>Swap Card</md-card-title>
    <span fxFlex></span>
    <md-icon>add_a_photo</md-icon>
  </md-card-header>
  <md-card-content>
  </md-card-content>
</md-card>
于 2017-07-24T21:00:31.797 回答
8

你在正确的轨道上,只需要添加正确的fxFlexAlign参数。对于您的问题,您将需要。

fxLayoutAlign="end start"

我已经在这个plunker中对其进行了测试。

html:

<md-card style="background-color:white;">
    <md-card-header style="background-color:white;">
        <md-card-title>Swap Card</md-card-title>
          <div class="flex-item" 
               fxFlex fxLayoutAlign="end start">
            <md-icon>add_a_photo</md-icon>
              Icon
          </div>
        </md-card-header>
    <md-card-content>
    </md-card-content>
</md-card>

您还可以了解如何fxLayoutAlign使用此文档示例

于 2017-07-25T01:58:58.503 回答