I am trying to make a search bar with multiple options and want to center it
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<div id="search_panel">
<div class='container'>
<form class="form-inline" role="form">
<!-- SEARCH PLACE -->
<div class="form-group">
<label class="sr-only" for="inputEmail">search</label>
<input id="where" name="where" type="search" placeholder="where you want to visit ...." class="form-control input-md" required="">
</div>
<!-- CHECK-IN DATE -->
<div class="form-group" id="start">
<i class="fa fa-calendar fa-2x"></i>
<input type='text' placeholder="Check-In Date" class="form-control" id='datepicker-start' />
</div>
<div class="form-group" id="end">
<i class="fa fa-calendar fa-2x"></i>
<input type='text' placeholder="Check-Out Date" class="form-control" id='datepicker-end' />
</div>
<!-- Button Drop Down -->
<div class="form-group">
<label class="sr-only" for="inputEmail">Select Basic</label>
<select id="selectbasic" name="selectbasic" class="form-control">
<option value="1">Option one</option>
<option value="2">Option two</option>
</select>
</div>
</form>
</div>
</div>
Inline Elements To center an inline element like a link or a span or an img, all you need is text-align: center .
You can use text-center for the row and can make sure the internal divs have display:inline-block (with not float ).
Inline block divs can be centered by applying text-align:center to their parent.
you can also combine classes
if you change your defnition from
<form class="form-inline" role="form">
to
<form class="form-inline text-center" role="form">
it should work!
Id like to keep as much as I can plain bootstrap before I add extra styles
and bootstrap comes with native alignment classes which can be found here: http://getbootstrap.com/css/#type-alignment
HTH
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With