0

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>
4
  • which library you're working with? Commented Jun 21, 2019 at 9:53
  • Can you provide your addKey method? @Developer Commented Jun 21, 2019 at 9:54
  • This is mostly to do with with the styles you use, are you using angular material design here? Commented Jun 21, 2019 at 9:55
  • i am working with js and css Commented Jun 21, 2019 at 10:05

2 Answers 2

1

This CSS should work

input { display: inline; }
Sign up to request clarification or add additional context in comments.

2 Comments

could you please let me know how will it fit in the code i have shared. Thanks
you have to add a <style> tag and put the css inside. In this way all the input elements will be aligned horizontally
0

Kindly add flex in display attribute as it provide horizontal alignment to the controls by default.

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

2 Comments

Could you add some more detail to your answer so that people who come across the same issue, can use your solution as well?
Yes sure.. @creyD

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.