简体   繁体   English

两列形式,每列中有动态行数

[英]two column form with dynamic number of rows in each column

I am trying to design the following form where there will be 2 column. 我正在尝试设计以下表格,其中将有2列。 Each column can have any number of form field like left column can have only one form field and right column can have also one form field only or left column can have two form field and right column can have three form field and vice versa. 每列可以具有任意数量的表单域,例如左列只能有一个表单域,右列也只能有一个表单域,或者左列可以有两个表单域,右列可以有三个表单域,反之亦然。

The way i am doing does not separates two columns. 我正在做的方式不会分开两列。 Here is what i have done 这是我所做的

Here is what i tried using flex 这是我尝试使用flex的东西

 .row { display: flex; } .input-wrapper { flex: 1; padding-left: 15px; } 
 <div class="row"> <div class="input-wrapper"> <label>Additional Space</label> <select> <option>hello</option> </select> </div> <div class="input-wrapper"> <label>Size</label> <input type="text" placeholder="length" /> </div> <div class="input-wrapper"> <label></label> <input type="text" placeholder="width" /> </div> <div class="input-wrapper"> <label></label> <select> <option>hello</option> </select> </div> </div> <br/><br/><br/><br/><br/> <div class="row"> <div class="input-wrapper"> <label>Additional Space</label> <select> <option>hello</option> </select> </div> <div class="input-wrapper"> <label>Size</label> <input type="text" placeholder="length" /> </div> </div> 

Here is the design 这是设计

在此处输入图片说明

First, you need to set width: 100% to the input type you want to span. 首先,您需要设置width: 100%为要跨越的输入类型。 In your layout, the container already takes the full width. 在您的布局中,容器已经占据了整个宽度。

You should also use display:flex on your input-wrapper and set 您还应该在input-wrapper上使用display:flex并进行设置

flex-direction: column;
justify-content: flex-end;

In order for the text to be shown first and the inputs on the second line. 为了先显示文本,然后在第二行显示输入内容。

 .row { display: flex; } .input-wrapper { flex: 1; padding-left: 15px; display: flex; flex-direction: column; justify-content: flex-end; } select{ width: 100%; } select, input{ border: 1px solid #e1e1e1; padding: 6px; border-radius: 3px; } label{ font-size: 14px; color: #d1d1d1; margin-bottom: 4px; } 
 <div class="row"> <div class="input-wrapper"> <label>Additional Space</label> <select> <option>hello</option> </select> </div> <div class="input-wrapper"> <label>Size</label> <input type="text" placeholder="length" /> </div> <div class="input-wrapper"> <label></label> <input type="text" placeholder="width" /> </div> <div class="input-wrapper"> <label></label> <select> <option>hello</option> </select> </div> </div> <br/><br/><br/><br/><br/> <div class="row"> <div class="input-wrapper"> <label>Additional Space</label> <select> <option>hello</option> </select> </div> <div class="input-wrapper"> <label>Size</label> <input type="text" placeholder="length" /> </div> </div> 

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

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