如何使用Flexbox将表单拉伸为水平div?

时间:2018-05-02 12:37:51

标签: html css html5 css3 flexbox

假设我们有一个带有输入和按钮元素的标准表单,如下例所示。我们如何使用CSS Flexbox水平和响应拉伸此表单?

<div>
   <form class="sampleform" onSubmit={this.onSubmit}>
       <input
            type="text"
            class="input-text"
            name="sampleinput"
            placeholder="A placeholder ..."
        />
        <button
             type="submit"
             class="button"
         >➕
         </button>
     </form>
</div>

1 个答案:

答案 0 :(得分:0)

像这样:

&#13;
&#13;
form {
  display: flex;
}
input {
  width: 100%;
}
&#13;
<div>
   <form class="sampleform" onSubmit={this.onSubmit}>
       <input
            type="text"
            class="input-text"
            name="sampleinput"
            placeholder="A placeholder ..."
        />
        <button
             type="submit"
             class="button"
         >➕
         </button>
     </form>
</div>
&#13;
&#13;
&#13;