I would like to get a form layout like below
https://jsfiddle.net/May_Y/6w9nd73c/20/
<form id="cat_select" class="form-inline">
<input class="c" name="c" id="c" type="text" style="width:10%"><br><br> Select any below:<br><br>
<input class="l0" name="l0" id="l0" type="text" style="width:30%">
<input class="l1" name="l1" id="l1" type="text" style="width:30%">
<input class="l2" name="l2" id="l2" type="text" style="width:30%">
<input class="l3" name="l3" id="l3" type="text" style="width:50%">
<input class="l4" name="l4" id="l4" type="text" style="width:50%">
<input class="l5" name="l5" id="l5" type="text" style="width:100%">
<input class="l6" name="l6" id="l6" type="text" style="width:100%">
<br>
<input `id="query" class="form-control mr-sm-2" type="query" placeholder="optional input" aria-label="query" name='query' value="" style="width:50%">
<select id="mySelect">
<option value="" disabled selected>Sort by</option>
<option>1</option>
<option>2</option>
</select><br><br>
<button class="btn btn-outline-success my-2 my-sm-0" type="submit" id="cat_submit">Submit</button>
</form>
but if I add bootstrap, <br>
does not work any more.
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
<form id="cat_select" class="form-inline">
<input class="c" name="c" id="c" type="text" style="width:10%"><br><br> Select any below:<br><br>
<input class="l0" name="l0" id="l0" type="text" style="width:30%">
<input class="l1" name="l1" id="l1" type="text" style="width:30%">
<input class="l2" name="l2" id="l2" type="text" style="width:30%">
<input class="l3" name="l3" id="l3" type="text" style="width:50%">
<input class="l4" name="l4" id="l4" type="text" style="width:50%">
<input class="l5" name="l5" id="l5" type="text" style="width:100%">
<input class="l6" name="l6" id="l6" type="text" style="width:100%">
<br>
<input `id="query" class="form-control mr-sm-2" type="query" placeholder="optional input" aria-label="query" name='query' value="" style="width:50%">
<select id="mySelect">
<option value="" disabled selected>Sort by</option>
<option>1</option>
<option>2</option>
</select><br><br>
<button class="btn btn-outline-success my-2 my-sm-0" type="submit" id="cat_submit">Submit</button>
</form>
I tried with <br style="clear: both;">
but it is not working as well.
How can I get the desired format with bootstrap.
I would like to have only id="query"
and id="mySelect"
in a different background color. Is this possible?
Thanks.
4
Answers
<br>
should work with bootstrap, may be something else is breaking yourtag, Can’t say anything on this without checking your actual code.
To set different background color you need to create some class in css and set that class to specific elements where you need that backgrund color. (in you case
id="query"
andid="mySelect"
)Style/CSS
.classname { background: red; }
Add class to elements you need
just remove class=”form-inline” it will work see the image
Your code is absolutely OK. I don’t know why do you have any problem, but I suggest you to use downloaded version of Bootstrap (no CDN). This is image what I get on the screen with your code:
On the other hand, it’s possible to change background color only for query and mySelect ID classes. Here is the image:
You only need to add additional classes. In my case there are test and test_2 classes. Check image:
br
are here direct children of aflex
box and are treated like any flex child (standing in the flex flow direction) .You may use :
<p class="w-100"><!-- will also break a line if boostrap is not loaded --></p>
instead<br><br>
it requires to modify the HTML
it requires to add extra css