TechGuy TechGuy - 5 months ago 11
CSS Question

How to display HTML form input elements (Bootstrap's class "form-group" ) inline?

I'm using bootstrap's form-group and form-control classes to create a simple HTML from. Please refer the screenshots. I tried setting the display property of form-control class to inline, but the html elements are not getting displayed inline. PFB my code snippet.

<div id="user_search" class="form-group" style="display:inline;">
<label for="search_id" class="label_font">Search Title</label>
<input type="text" class="form-control" id="search_id" placeholder="Movie Title, TV Show title..." size="40">
<label for="genre_id" >Genre</label>
<select id="genre_id">
<option></option>
<option>Action</option>
<option>Adventure</option>
<option>Animation</option>
<option>Biography</option>
<option>Comedy</option>
<option>Crime</option>
<option>Documentary</option>
<option>Drama</option>
<option>Family</option>
<option>Fantasy</option>
<option>Film-Noir</option>
<option>Game-Show</option>
<option>History</option>
<option>Horror</option>
<option>Music</option>
<option>Musical</option>
<option>Mystery</option>
<option>News</option>
<option>Reality-TV</option>
<option>Romance</option>
<option>Sci-Fi</option>
<option>Sport</option>
<option>Talk-Show</option>
<option>Thriller</option>
<option>War</option>
<option>Western</option>
</select>
<label for="type_id" >Title Type</label>
<select id="type_id">
<option></option>
<option>Movie</option>
<option>TV Show</option>
</select>
<label for="year_id" >Year</label>
<input type="number" width="10" min="1900" max="2025" step="1" value="2016" id="year_id">
<button type="button" id="search_Title">Search Title</button>

</div>


CSS file

.form-control{
display:inline;}


I also tried display:inline!important. But couldn't see any difference. I want all the form to be displayed in a single line using bootstrap's form-group and form-control classesenter image description here.

Answer

You should simply use the form-inline class ... as per Bootstrap documentation. Basically wrap the div with another which has the 'form-inline' class and you should be good. No need for your display:inline; additional css.