I am trying to align inputs and buttons using the .input-group class as shown here.
It works well and shows the desired output when I place a button before the text box.
But, when I place the button next to the text box, the button doesn't stay close to the text box.
I am using Bootstrap 3 in my ASP.NET project, created using Visual Studio 2015 Community Edition.
Here is the code:
<div class="row">
<div class="col-lg-6">
<div class="input-group">
<span class="input-group-btn">
<button class="btn btn-default" type="button">Go!</button>
</span>
<input type="text" class="form-control" placeholder="Search for...">
</div><!-- /input-group -->
</div><!-- /.col-lg-6 -->
<div class="col-lg-6">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search for...">
<span class="input-group-btn">
<button class="btn btn-default" type="button">Go!</button>
</span>
</div><!-- /input-group -->
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
I had the exact same problem and I looked at cale_b's fiddle and it appeared correct for me. So I scratched my head trying to figure out what was different in my environment. I noticed that in my site.css (my custom css for my app), I had the following:
/* Set width on the form input elements since they're 100% wide by default */
input,
select,
textarea {
max-width: 280px;
}
Once I removed (or commented out) that CSS, then it worked. But now I need to find a different approach to default the max-widths on my inputs. Oh well, at least it solved my problem, hope it solved yours.
Related
I'm making a form-inline using Bootstrap 4, but when I use a button, the position of the button is always at the top of the row, I want the button's position to be the same as the input field's position, which is in the middle of the row.
<form role="form" id="form_tambah_kriteria" class="margin-bottom-0">
<div class="form-row">
<div class="form-group col-md-4">
<label>Tipe Decision Maker</label>
<div class="input-group">
<div class="input-group-append"><span class="input-group-text"><i class="ion-ios-contacts"></i></span></div>
<input type="text" name="tipe_dm[]" class="form-control" placeholder="Tipe Decision Maker">
</div>
</div>
<div class="form-group col-md-4">
<label>Owned by:</label>
<div class="input-group">
<select class="form-control" name="owner_dm">
<option value="">0</option>
<option value="1">1</option>
</select>
</div>
</div>
<button class="btn btn-danger">Delete</button>
</div>
</form>
The following is Codepen
The simple fix is to wrap the button in a form-group and prefix it with some invisible text ( or <br />). But it would be dead wrong, just a handy hack, because it would simply hide the underlying problem with your codepen.
The proper fix would be to:
use latest stable version of Bootstrap - your pen currently uses v4.0.0-alpha5 which doesn't contain a lot of bugfixes and, among others, does not contain Bootstrap's flexbox classes)
wrap the button in a .form-group.col-md-4
use d-flex align-items-end classes on the .form-row
Working example: https://codepen.io/andrei-gheorghiu/pen/KKKNxZg
Note: until you start using the latest stable version of Bootstrap's CSS, you'll keep running into problems which seemingly don't make any sense, because the version you're using is a pre-release which does not include a lot of what most Bootstrap 4 examples take for granted.
the solution is easy just add <br> before the button Delete for new line...like this:
<br> <button class="btn btn-danger">Delete</button>
You should put the button in the third column grid and use the <br /> .
you should do it as below:
<div class="form-group col-md-4">
<br />
<button class="btn btn-danger">Delete</button>
</div>
I would like to place Have an account?, Login button, and Link A Link B directly underneath something something something something, Enter Zip Code input field and Enter Zip Code button.
The way I've set up my Bootstrap (version 3.3.7) and HTML, I'd think that it would've appeared underneath but it's actually displaying the complete opposite of what I expect. Instead, it's all the way on the left side as per the picture below.
Why's is carrying out this behavior? If more information is needed please let me know.
picture of what I'm describing
<link href="https://stackpath.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="col-7">
<form class="pull-right col-12 zipSection">
<h6 class="pull-right">something something something something</h6>
<div class="form-group">
<input type="text" class="form-control" placeholder="Enter Zip Code">
</div>
<button type="submit" class="btn btn-default center-block enterZipCodeButton">Enter Zip Code</button>
</form>
<div class="col-12">
<p class="col-12">Have an account?</p>
<button type="submit" class="loginButton" onclick="document.location = '/'">Login</button>
Link A
Link B
</div>
</div>
</div>
Your form has a class called pull-right (which has been renamed to float-right in Bootstrap 4). What that does is forces the div to the far right. Since this is bootstrap, everything else adapts, which means the div which theoretically should be under, gets forced up to the top row, and to the left (since left-alignment is the default). A solution to that is to use the class of row from the Bootstrap grid system. Every row you want, you make a new div with a class of row. This way, they will now be under each other.
However, the Have an account? would still be on the left. To fix that, give it a class of pull-right.
<link href="https://stackpath.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid">
<div class="row">
<div class="col-7">
<form class="pull-right col-12 zipSection">
<h6 class="pull-right">something something something something</h6>
<div class="form-group">
<input type="text" class="form-control" placeholder="Enter Zip Code">
</div>
<button type="submit" class="btn btn-default center-block enterZipCodeButton">Enter Zip Code</button>
</form>
</div>
</div>
<div class="row">
<div class="col-12 pull-right">
<p class="col-12">Have an account?</p>
<button type="submit" class="loginButton" onclick="document.location = '/'">Login</button>
Link A
Link B
</div>
</div>
</div>
I want to make full with the button on right side.
I added btn-block on button element but it's dont working i don't know why.
Jsfiddle Here
<div class="fieldset">
<div class="field qty">
<label class="label" for="qty"><span>Qlty</span></label>
<div class="control control-qty-cart">
<span class="quantity-controls quantity-minus"></span>
<input type="number" name="qty" id="qty" maxlength="12" value="1" title="Aantal" class="qty-default input-text qty" data-validate="{"required-number":true,"validate-item-quantity":{"minAllowed":1}}">
</div>
</div>
<div class="actions">
<button type="submit" title="In Winkelwagen" class="action primary tocart btn-block" id="product-addtocart-button">
<span>In Winkelwagen</span>
</button>
</div>
</div>
Not sure where you took that bootstrap code from. I tried with this links and it worked. Also better to add it as an external library rather than to put the code there directly.
For bootstrap 3 (css): https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css
For bootstrap 3 (js): https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js
For bootstrap 4 get the cdn from this link: https://getbootstrap.com
I need to use text box with a glyphicon in one straight line, here what I've done:
http://plnkr.co/edit/GZQeGTqDsvTh9XsXmMFy?p=preview
<div class="w3-row" style="vertical-align:middle">
<div class="w3-col s6">
<input ng-readonly="true" type="text" ng-model="login" placeholder="Login" class="form-control" />
</div>
<div class="w3-col s4">
<input class="form-control" ng-readonly="true" type="text" ng-model="password" placeholder="Password" />
</div>
<div class="w3-col s2">
<button class="glyphicon glyphicon-refresh btn btn-default"></button>
</div>
</div>
It looks alright, but the glyph button is slightly below than the bottom line of text inputs, I want its height to be stretched to those inputs, or, at least, to be in the middle relatively to their center, then it will be good looking.
Please help me find the solution.
Notice:
Either w3.css or angular-ui's bootstrap can be used to solve this issue.
The solution should not depend on using the "form-inline".
The best solution would be the one which doesn't use "row" "col" classes whatsoever, because they make it impossible to stretch line horizontally to 100% and fill each column without making it look ugly!
Thank you.
change your button markup to this
<button class="btn btn-default">
<span class="glyphicon glyphicon-refresh "></span>
</button>
plunk
I'm using Twitter Bootstrap in a Rails application. I'm trying to line up a search field with the Search button and a Help button which will use the Accordion Javascript control to expand the area below with Help content.
I have everything working, but, the Help button isn't staying on the same line as the other controls. The accordion control requires a DIV so I'm not sure if that's causing a problem. Instead of staying on the same line the Help button appears just below the search field left aligned.
Here is my code:
<p><strong>Enter Search Criteria</strong></p>
<form class="form-inline">
<input type="text" class="input-large" placeholder="Name, Phone, Conf Rm" autofocus >
<button type="submit" class="btn">Search</button>
<div class="details">
<!-- accordian button -->
<div class="accordion">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapseHelp"> <button type="link" class="btn btn-info btn-small">
<i class="icon-question-sign"></i>
</button></a>
</div>
</form>
</div>
<!-- Accordian area -->
<div id="collapseHelp" class="accordion-body collapse style="height: 0px; ">
<div class="accordion-inner">
<p><strong>Person Search:</strong> Last Name, First Name (e.g. Smith, John)</p>
<p><strong>Conference Room Search:</strong> Plaza-Building, Suite-Name (e.g South-I2W-20E-1)</p>
<p><strong>Phone Number Search:</strong> Please provide at least the last 4 digits of the phone number (e.g. 8686)</p>
</div>
</div>
<!-- End accordian area -->
All help is greatly appreciated.
Thanks
Your accordion button does not need to reside within a container in order to function, so just remove the .details and .accordion containers and your button should line up with the rest of the control buttons just fine.
HTML
<p><strong>Enter Search Criteria</strong></p>
<form class="form-inline">
<input type="text" class="input-large" placeholder="Name, Phone, Conf Rm" autofocus >
<button type="submit" class="btn">Search</button>
<!-- accordian button -->
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapseHelp"> <button type="link" class="btn btn-info btn-small">
<i class="icon-question-sign"></i>
</button></a>
</form>
<!-- Accordian area -->
<div id="collapseHelp" class="accordion-body collapse" style="height: 0px; ">
<div class="accordion-inner">
<p><strong>Person Search:</strong> Last Name, First Name (e.g. Smith, John)</p>
<p><strong>Conference Room Search:</strong> Plaza-Building, Suite-Name (e.g South-I2W-20E-1)</p>
<p><strong>Phone Number Search:</strong> Please provide at least the last 4 digits of the phone number (e.g. 8686)</p>
</div>
</div>
<!-- End accordian area -->
Demo:
http://jsbin.com/eyajig/1