I have been struggling because I have this form that has different inputs on sub divs. Whenever I put the opening form tag before the first input, the line breaks. If I put it after it, it will stay fine. I have tried adding:
display:inline
to different classes, but it doesn't seem to do the trick.
Here is the fiddle: https://jsfiddle.net/tL50dhcu/
Can anyone help me keep it in line?
.form-horizontal {
display: flex;
flex-flow: row nowrap;
}
if you make the container of the form flex , and set it to nowrap
EDIT: Here is a more succinct way to do what you are trying to do: http://codepen.io/dcain19/pen/xVVyao
Try the example below. Notice how the search input was put inside the input-group-btn class. Now, you will have to change your border-radius on the button to make the right borders rounded, but that should get you what you need.
<form method="post" class="form-horizontal" role="form" action="{% url 'search' %}">
<div class="input-group-btn">
<div class="btn-group" role="group">
<input type="text" class="form-control" id="searchInput" placeholder="Search" name="search" required />
<div class="dropdown dropdown-lg">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><span class="caret"></span></button>
<div class="dropdown-menu dropdown-menu-right" role="menu">
<div class="form-group">
<label for="filter">Industry</label>
<select class="form-control" id="searchIndustry" name="industry">
<option value="any">Any</option>
</select>
</div>
<div class="form-group">
<label for="filter">Country</label>
<select class="form-control" id="searchCountry" name="country">
<option value="any">Any</option>
</select>
</div>
</div>
</div>
<button type="submit" class="btn btn-primary" type="submit"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></button>
</form>
Related
There must be a way to display one form next to another in Bootstrap without having to manually set the CSS to display:inline-block.
I've created a fiddle here.
I've used the form-inline class but that doesnt seem to make much of a difference. Am I missing something?
Here is solution:
Add a class,"pull-left" with form-inline.
Hope this will help.
You could put two forms side by side using the grid system. For example:
<div class="container">
<div class="col-xs-6">
<form class='form-inline'>
<div class="input-group">
<input type="date"class="form-control">
<span class="input-group-btn">
<button type='submit' class="btn btn-secondary" type="button">View</button>
</span>
</div>
</form>
</div>
<div class="col-xs-6">
<form class='form-inline'>
<div class="input-group">
<input type="date"class="form-control">
<span class="input-group-btn">
<button type='submit' class="btn btn-secondary" type="button">View</button>
</span>
</div>
</form>
</div>
See a working example here on JS Fiddle
You should use input-group class, as shown here:innput-group
By applying col class in forms you will get the proper result.
<div class='container'>
<div class='row m-b-20 title'>
<div class='col-sm-6'>
<h1>Test page</h1>
</div>
<div class='col-sm-6 text-right'>
<form action='/error-logs' method='POST' class='input-group pull-left'>
<button type='' name='' class='btn btn-default' alt='' title=''><span class='fa fa-floppy-o'></span>Button 1</button>
</form>
<form action='/error-logs' method='POST' class='input-group pull-right'>
<div class="input-group">
<input type="date" name='fromdate' class="form-control">
<span class="input-group-btn">
<button type='submit' class="btn btn-secondary" type="button">View</button>
</span>
</div>
</form>
</div>
</div>
</div>
i-ve stumbled on this searching for an aswer for similar problem
i-ve solved it by doing this
<form action="cosprocess.php" method="post" style="float: left; padding: 1px;">
Bootstrap 3 was likely used when this question was originally asked. Sangrai's answer of using pull-left may have worked well in 3, but unfortunately it does not in Bootstrap 4 when there are too many form controls to fit onto a single line. The controls don't align well.
The following has worked well for me in Bootstrap 4. It may be risky, though, since the Bootstrap documentation says nothing about having an inline form within an inline form.
<div class="form-inline">
<form class="form-inline">
<!-- First set of form controls go here. -->
</form>
<form class="form-inline">
<!-- Second set of form controls go here. -->
</form>
</div>
FYI - The Bootstrap 4.6 documentation says that pull-left was removed because it was redundant to float-left.
Make the parent div come under a row and have 12 col length for all vw.
Use buttons after input field and put all of them in a single form with class in-line.
fiddle
`
<div class="input-group">
<input type="date" name='fromdate' class="form-control">
<span class="input-group-btn">
<button type='submit' class="btn btn-secondary" type="button">View</button>
<button type='' name='' class='btn btn-default' alt='' title=''><span class='fa fa-floppy-o'></span>Button 1</button>
</span>
</div>
</form>`
I used an input group straight from the bootstrap documentation, and for some reason the button is way bigger than the text input.
Here's the HTML:
<div class="jumbotron">
<div class="input-group">
<input ng-model="businessName" ng-model="chosenPlace" googleplace type="text" class="form-control input-lg">
<span class="input-group-btn">
<button ng-click="findGPlace2()" class="btn btn-default" type="button">Find!</button>
</span>
</div>
</div>
I haven't made any changes to the css, just vanilla bootstrap.
Try to use the samples in Boostrap page. This is the bootply link you can customize it.
<div class="jumbotron">
<form class="form-horizontal" role="form">
<div class="input-group">
<input ng-model="businessName" ng-model="chosenPlace" class="form-control input-lg">
<span class="input-group-btn">
<button ng-click="findGPlace2()" class="btn btn-default btn-lg" type="button">Find!</button>
</span>
</div>
</form>
</div>
I have this html:
<button type="submit" class="btn btn-default pull-right" id="loginBtn" >Login</button>
The addition of pull-right makes button cut off from bottom:
How can I fix this?
Make sure it's inside a Bootstrap form-group..
<form class="form col-md-12 center-block">
<div class="form-group">
<input type="text" class="form-control input-lg" placeholder="Email">
</div>
<div class="form-group">
<input type="password" class="form-control input-lg" placeholder="Password">
</div>
<div class="form-group">
<button class="btn btn-primary btn-lg pull-right">Login</button>
</div>
</form>
Demo: http://bootply.com/106344
Bootstrap 3 button class "btn" adds display: inline-block, which "Displays an element as an inline-level block container. The inside of this block is formatted as block-level box, and the element itself is formatted as an inline-level box" (http://www.w3schools.com/cssref/pr_class_display.asp). A way around this would be to try the class "clearfix" around the parent (as was explained above). You could also try wrapping the button in a div:
<div class="pull-right"><button></button></div>
I am attempting to "pretty up" a search a in my app. It consists of a single textbox, plus a dropdown for selecting a "type" (analogous to "Sent Items", "Deleted Items", "Inbox" in an outlook type application), plus a "go" button to execute the search.
I have prepared a fiddle below. Notice that reversing the order of the dropdown and go button seems to have add space between the controls (which is not what I'd like). Is this something I'm doing incorrectly in my html, or should I be logging this as an issue with the bootstrap people?
http://jsfiddle.net/ebV3v/
<form class="clearfix" role="form" style="padding:5px; border:solid 1px red;">
<div class="input-group">
<input id="searchText" type="text" placeholder="" class="form-control" />
<div class="input-group-btn">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" style="width:120px;">
<span>[ -- Select -- ]</span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu pull-right">
<li><button>X</button></li>
<li><button>Y</button></li>
<li><button>Z</button></li>
</ul>
<button type="submit" class="btn btn-default">Search</button>
</div>
</div>
</form>
<form class="clearfix" role="form" style="margin-top:5px; padding:5px; border:solid 1px green;">
<div class="input-group">
<input id="searchText" type="text" placeholder="" class="form-control" />
<div class="input-group-btn">
<button type="submit" class="btn btn-default">Search</button>
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" style="width:120px;">
<span>[ -- Select -- ]</span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu pull-right">
<li><button>X</button></li>
<li><button>Y</button></li>
<li><button>Z</button></li>
</ul>
</div>
</div>
</form>
Place your <ul> element after the Search button, and the space is gone, and the dropdown list won't be affected.
I will investigate further and search for a way to leave the <ul> element there not taking this space. But my suggestion should solve the problem without affecting anything.
EDIT
It's not a <ul> problem exactly. The exact bug is caused by these buttons inline-block display, which comes from Bootstrap. As they are inline-block, any space between </button> and <ul> is taken as a text blank space. You should remove all spaces between them and it's fixed (I had to remove the line break between them in the source code too).
Updated Fiddle
I'm trying to get a select, an input, and a button to align inside an inline form that's within a popover, but as of yet I've had no success. I've followed the docs and tried to experiment with different widths for the select, but to no avail
Edit: Updated to reflect Eric B's suggestion
Code:
<li><a data-placement="bottom" data-toggle="popover" data-container="body" type="button" href="#" id="login" >Login</a></li>
<div id="popover-head" class="hide">Login</div>
<div id="popover-content" class="hide">
<form class="form-inline" role="form">
<div class="form-group">
<select class="form-control">
<option>NA</option>
<option>RU</option>
<option>EU</option>
<option>SEA</option>
</select>
<input type="text" placeholder="Name" class="form-control" maxlength="5">
<button type="submit" class="btn btn-primary">Go To Login »</button>
</div>
</form>
</div>
Output:
Example http://puu.sh/4XWmi.png
I think you're seeing 2 problems..
First, in Bootstrap 3, the form inputs are no longer set to a specific width, so you need to set a width for the inputs to prevent stacking. This can be done by overriding .form-control or set the width by using a style= attribute on your inputs.
Secondly, the Bootstrap .popover has a max-width of 276px, so you need to increase the width accordingly...
.form-control {width:120px;}
.popover {max-width:400px;}
Working demo: http://bootply.com/89823
Try NOT wrapping each one in their own <div> tag. But wrapping all 3 in one <div> tag.
<li><a data-placement="bottom" data-toggle="popover" data-container="body" type="button" href="#" id="login" >Login</a></li>
<div id="popover-head" class="hide">Login</div>
<div id="popover-content" class="hide">
<form class="form-inline" role="form">
<div class="form-group">
<select class="form-control" width="20%">
<option>NA</option>
<option>RU</option>
<option>EU</option>
<option>SEA</option>
</select>
<input type="text" placeholder="Name" class="form-control" maxlength="5" width="20%">
<button type="submit" class="btn btn-primary" width="20%">Go »</button>
</div>
</form>
</div>