Angular 2 Flex 布局右对齐图标

Tom*_*myK 5 css flexbox angular-material2 angular-flex-layout angular

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

下面的 snipper 没有<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>
Run Code Online (Sandbox Code Playgroud)

Kim*_*ern 8

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

<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>
Run Code Online (Sandbox Code Playgroud)


Neh*_*hal 8

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

fxLayoutAlign="end start"
Run Code Online (Sandbox Code Playgroud)

我已经在这个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>
Run Code Online (Sandbox Code Playgroud)

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