Haga la entrada de texto y el botón en la misma fila con Bootstrap

I am using basic file upload bootstrap-fileupload.js to give me a filename and button and want to repeat the format with a text input and button.

<div class="form-group">
    <label class="control-label">Source File Name</label>
    <div class="fileupload fileupload-new" data-provides="fileupload">
        <div class="input-group">
            <div class="form-control uneditable-input"><i class="icon-file fileupload-exists"></i> 

            </div>
            <div class="input-group-btn">
                <a class="btn btn-default btn-file">
                    <span class="fileupload-new">Select file</span>
                    <span class="fileupload-exists">Change</span>
                    <input type="file" class="file-input"/></a>
                <a href="#" class="btn btn-default fileupload-exists" data-dismiss="fileupload">Remove</a>
            </div>
        </div>
    </div>
 </div>
 <form id="frmOptions" method="post" class="form-inline span12">

 <div class="row-fluid">   
<div class="form-group">
    <label class="control-label">File Name on Upload</label>
    <div class="input-group ">
        <input id="uploadname" type="text" class="form-control">
        <a class="btn btn-default go inline">Upload to DocMan</a>
    </div>
</div>

</div>
</form>

Page hosted here https://googledrive.com/host/0B90FGJizRd-gbm1JRUswYUY5dE0/bootstrap/ I have tried variations of this with no effect. Basically I want two similar looking full width rows, each with a text field and a button. Any advice is welcome.

preguntado el 10 de septiembre de 13 a las 00:09

4 Respuestas

You use the input group

<div class="input-group">
      <input type="text" class="form-control">
      <span class="input-group-btn">
        <button class="btn btn-default" type="button">Go!</button>
      </span>
    </div>

contestado el 15 de mayo de 14 a las 22:05

hmm doesn't work for me.. the button goes to a new line - deportes

Note: This works with Bootstrap 3. If it does not work for you, check if you are using an older Bootstrap version. - user1438038

Prueba esto:

  1. Remove class "form-inline" from the form
  2. Add class "input-group-btn" to the button

Resulting html:

<form id="frmOptions" method="post" class="span12">
    <div class="row-fluid">   
        <div class="form-group">
            <label class="control-label">File Name on Upload</label>
            <div class="input-group">
                <input id="uploadname" type="text" class="form-control">
                <a class="input-group-btn btn btn-default go inline">Upload to DocMan</a>
            </div>
        </div>
    </div>
</form>

Respondido 09 ago 18, 11:08

This makes the button float all the way to the right. How can I force it to stay next to the text input? - daniel gabriel

You can wrap it inside a div with the "navbar-form" class. That will put everything inside inline.

Respondido 17 Jul 15, 21:07

Una opción es anular el display:block; style of the class form-control. I have posted sample code in following reply:

bootstrap: align input with button

contestado el 23 de mayo de 17 a las 11:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.