如何使用flexbox将两个元素放在同一行?

时间:2016-10-19 01:45:27

标签: css flexbox polymer-1.0

  <template>
<style>
  .container {
    display: flex;
    justify-content: space-between;
    width: 100%;
  }
  .display {
    display: flex;
    width: 100%;
    height: 85%;
  }
  .input {
    display: inline-block;
    flex-direction: row;
    align-self: flex-end;
    justify-content: flex-start;
    width:100%;
  }

</style>

<paper-drawer-panel>
  <paper-header-panel drawer>
    <paper-toolbar>
      <div>Application</div>
    </paper-toolbar>
  </paper-header-panel>
  <paper-header-panel main>
  <!--toolbar-->
    <paper-toolbar>
      <paper-icon-button icon="menu" paper-drawer-toggle></paper-icon-button>
      <div class="container" tool layout horizontal>
        <div class="app-title" ><span>Cat Chat</span></div>

      <div class="account-icon">
        <iron-icon icon="account-circle"></iron-icon>
        <span>number of people</span>
        </div>
      </div>

    </paper-toolbar>

    <!--Main Content -->
    <div class="display" flex>
    </div>
      <div class="input" flex>
          <paper-input  label="Type message..." value={{input}}></paper-input>
          <paper-fab  icon="send" id="sendButton" on-tap="{{sendMyMessage}}"></paper-fab>
      </div>
  </paper-header-panel>
</paper-drawer-panel>

我试图在同一行上排列纸张输入和纸张按钮,输入跨越大部分宽度,按钮结束。目前,按钮位于输入下方。如何对齐它们?enter image description here

1 个答案:

答案 0 :(得分:1)

您未将display: flex应用于.input选择器。

HTML:

 <div class="display"> 
 </div> 
 <div class="input">
     <paper-input  label="Type message..." value={{input}}></paper-input>
     <paper-fab  icon="send" id="sendButton" on-tap="{{sendMyMessage}}"></paper-fab>
 </div>

CSS:

.input {
    display: flex;
    flex-direction: row;
    align-self: flex-end;
    justify-content: flex-start;
    width:100%;
  }