简体   繁体   中英

how to add input boxes horizontally on button click

I need to add text input boxes aligned horizontally on the click of a button Every time i click "add attribute" a new input box should be created but placed horizontally right the previous input box. Is there a way to do this in vue.js

This adds input boxes, but vertically one below the other, i want them to be horizontally aligned

<hr>
<div class="md-layout">
    <md-button v-on:click="addKey" class="md-raised md-primary">Add Attribute</md-button>
</div>
<md-content class="md-scrollbar" style="max-width:90vh; overflow: auto">
    <div class="md-layout" v-for="value, index in keyList">
        <md-field>
            <md-input type="text" v-model="value.key" v-bind:id="'keyInput' + index" @keyup.enter="searchKey(value.key, index)"
                @focus="updateKey(index)">
            </md-input>
            <md-input type="text" v-model="value.key" v-bind:id="'keyInput' + index" @keyup.enter="searchKey(value.key, index)"
                @focus="updateKey(index)">
            </md-input>
            <md-button class="md-raised md-primary" :id="'keyButton' + index" @click="removeKey(index)"> X </md-button>
        </md-field>
    </div>

该CSS应该可以工作

input { display: inline; }

请在display属性中添加flex,因为默认情况下它为控件提供水平对齐。

<md-field style="display: flex;">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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