bootstrap: form-control size doesnt change based on parent div col size - css

I am trying to use increase the size of my text box but changing col-md-* value doesn't seem to affect the child input form-control textbox.
Example:
<form id="myForm">
<div class="row">
<div class="col-md-2">
Name:
</div>
<div class="col-md-8">
<input name="Name" type="text" placeholder="Enter a name ..." class="form-control" required="required" />
</div>
</div>
</form>
In above code the text input size doesn't increase to what I think should be larger if I used col-md-8. The text box size is same whether I use col-md-4 or col-md-6 also. Is it because form-control class in bootstrap defines a size? If so how can this be fixed?

Try this its work for me
<div class="row">
<form id="myForm">
<div class="col-md-2">
Name:
</div>
<div class="col-md-8">
<input name="Name" type="text" placeholder="Enter a name ..." class="form-control" required="required" />
</div>
</form>
</div>

Related

Can't change input form width

I'm making a form and I want the left half of the page to fill up the section. I have tried col-lg-4, changing the CSS width to 100%, nothing is changing the actual input field. I have searched Stack Overflow, but I couldn't find anything that worked. The first picture is what I have, and the second picture is what I was trying to recreate.
<section class="col-md-6">
<form class="form-group row">
<div class="form-group">
<input type="text" class="form-control" id="inputEmail" placeholder="Cool Person">
</div>
<div class="form-group">
<input type="email" class="form-control" id="inputEmail" placeholder="you#yourdomain.com">
</div>
<div class="form-group">
<input type="text" class="form-control" id="inputSubject" placeholder="what's up?">
</div>
<div class="form-group">
<textarea rows="6" class="form-control" placeholder="What's on your mind?"></textarea>
</div>
</form>
</section>
set css display property to inline-block and give width 100%
.form-control{
display:inline-block;
width:100%
}
ok first of all you cannot have two elements with the same id, because only the last element will get to have that id and the first one won't
to answer your question try to this in css
.form-group, .form-control {width : 100%;}
I'd rather though you'd give an id to your form and then call these classes as its children, like -#form_id .form-group {...
use bootstrap div as mentioned below and try
<div class="container">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<input type="text" class="form-control" id="inputEmail"
placeholder="Cool Person">
</div>
<div class="form-group">
<input type="email" class="form-control" id="inputEmail" placeholder="you#yourdomain.com">
</div>
<div class="form-group">
<input type="text" class="form-control" id="inputSubject" placeholder="what's up?">
</div>
<div class="form-group">
<textarea rows="6" class="form-control" placeholder="What's on your mind?"></textarea>
</div>
</div>
<div class="col-sm-6">
Maps Section Comes Here!
</div>
</div>
</div>

Bootstrap Automatically Adjust Based on Screen Size

I create design interface for web using Bootstrap 3. If it shown in large screen size, it looks like this:
but, if it shown in small screen size, it looks like this:
I've problem when it will be shown in small screen size. The script what I've done in
Bootply is not compatible in small size.
You need to place your label tags with your input tags inside the same columns.
DEMO
<div class="row">
<div class="col-md-3">
<label>Label1</label>
<input type="text" class="form-control" value="text1">
</div>
<div class="col-md-3">
<label>Label2</label>
<input type="text" class="form-control" value="text2">
</div>
<div class="col-md-3">
<label>Label3</label>
<input type="text" class="form-control" value="text3">
</div>
<div class="col-md-3">
<label>Label4</label>
<input type="text" class="form-control" value="text4">
</div>
</div>

Narrow size of inputs in bootstrap 3

I want to narrow the size of input boxes in the horizontal form.
I used col-sm-4 to make text boxes narrower.
<form class="form-horizontal">
<div class=" form-group">
<label class="col-sm-2 control-label">date</label>
<div class="col-sm-4">
<input name="date" type="text" class="form-control" />
</div>
</div>
</form>
For big size it works, however when I resize the form and make it smaller, suddenly, the length of input box will stretch and become larger. So for big screens the input will have 230px and for smaller screen it will have 608px
The fiddel http://jsfiddle.net/3YWkd/
I want that the size of text box remain the same during page shrink.
You just need to add the mobile (xs) classes, like so:
<div class="col-sm-4 col-xs-4">
<input name="fromDate" type="text" class="form-control" />
</div>
Or just leave the col-xs-4, no need for the sm in this case.
Edit:
Re: your comment, you may use slightly different html, like soQ
<div class=" form-group">
<div class="col-xs-2">
<label class="control-label" for="fromDate">date</label>
</div>
<div class="col-xs-4">
<input name="fromDate" type="text" class="form-control" />
</div>
</div>
fiddle
This should do it:
<form class="form-horizontal">
<div class=" form-group">
<label class="col-sm-2 col-xs-12 control-label">date</label>
<div class="col-sm-4 col-xs-4">
<input name="date" type="text" class="form-control" />
</div>
</div>
</form>

My bootstrap form has two un-clickable inputs, can't figure out why

I have a bootstrap 3 form.
when its in the tabled and larger media query state, the middle input field is somehow overlaying the two inputs above making them none clickable jsfiddle.net/wT7gp/.
I have put an example in jsfiddle. (remember to make it wide enough to see the problem)
Repro:
Open link.
make the outwindow large.
click the input for firstname.
Expected it to start typing state, but nothing happens.
Hope someone here can explan what I did to cause it :) I failed at finding the issue. (other then yes the middle element is overlaying the two others.
You should be wrapping your rows of form groups in div with row class like so:
Fiddle: http://jsfiddle.net/wT7gp/1/
HTML
<div class="row">
<div class="form-group col-sm-6">
<input class="form-control input-lg " placeholder="First Name" id="first-name" tabindex="1" name="FirstName" data-bind="value: firstName" type="text" maxlength="50" />
<label for="first-name" style="display:none;" data-bind="validationMessage: firstName, css: { error: !firstName.isValid() }" class="error"></label>
</div>
<div class=" form-group col-sm-6">
<input class="form-control input-lg " placeholder="Last Name" id="last-name" tabindex="2" name="LastName" data-bind="value: lastName" type="text" maxlength="50" />
<label for="last-name" style="display:none;" data-bind="validationMessage: lastName, css: { error: !lastName.isValid() }" class="error"></label>
</div>
</div>
<div class="row">
<div class="col-sm-12 form-group">
<input class="form-control input-lg " placeholder="Email" id="email" tabindex="3" name="Email" data-bind="value: email" type="email" maxlength="50" />
<label for="email" style="display:none;" data-bind="validationMessage: email, css: { error: !email.isValid() }" class="error"></label>
</div>
</div>
<div class="row">
<div class="col-sm-6 form-group">
<input class="form-control input-lg " placeholder="Choose a password" id="password1" tabindex="4" name="Password" data-bind="value: password" type="password" />
<label for="#Html.CamelCaseName(Name)" style="display:none;" data-bind="validationMessage: password , css: { error: !password.isValid() }" class="error"></label>
</div>
<div class="col-sm-6 form-group">
<input class="form-control input-lg " placeholder="password, again" id="password2" tabindex="5" name="ConfirmPassword" data-bind="value: confirmPassword" type="password" />
<label for="#Html.CamelCaseName(Name)" style="display:none;" data-bind="validationMessage: confirmPassword , css: { error: !confirmPassword.isValid() }" class="error"></label>
</div>
</div>
I had the same problem. It was caused by a div covering my input controls. It seemed the div 'knew no bounds'.
So when I worked out which div was causing the problem I applied the overflow:hidden; style.
I'm guessing that's why the row class worked for Kevin Pei - maybe it keeps the col divs contained.
Aside: I used Firefox Firebug to show me which div was covering my controls.
We had a very similar problem within our web application. Using bootstrap 3.3.7 our signup form did not work any more on iPhones. The initial form looked like this:
<form ...>
<div class="col-xs-12 col-sm-6">
<div class="form-group string required">
<input ...>
</div>
</div>
<div class="col-xs-12 col-sm-6">
<div class="form-group string required">
<input ...>
</div>
</div>
<div class="col-sm-6 col-md-8">
<div class="form-group string required">
<input ...>
</div>
</div>
<div class="col-sm-6 col-md-4">
<input type="submit" value="Register">
</div>
</form>
The problem was caused by the last two div elements which did not have corresponding class definitions for the xs-size. So on iPhone the <div class="col-sm-6 col-md-4"> class resulted in a very big div overlaying the whole form and preventing touch events for input fields beneath the div.
The solution is simply adding a xs-size class to the div and everything worked well on iPhones. In our case we adjusted the form like that:
<div class="col-xs-12 col-sm-6 col-md-8">
<div class="form-group string required">
<input ...>
</div>
</div>
In my case i set z-index:1 for the controls not allowing inputs and no z-index setting for the controls allowing inputs.

twitter bootstrap span not aligning properly

For some reason, when I apply spans the spans do not align themselves into a proper grid. It doesn't seem to matter what type of element I apply the span to, in this case it is inputs. I obviously want them to align themselves, what am I doing wrong?
Fiddle here: http://jsfiddle.net/fKQsj/
<div class="row-fluid">
<div class="span12">
<input type="text" class="span4" placeholder="First" />
<input type="text" class="span4" placeholder="Middle" />
<input type="text" class="span4" placeholder="Last" />
</div>
</div>
<div class="row-fluid">
<div class="span12">
<input type="text" class="span4" placeholder="City" />
<input type="text" class="span2" placeholder="State" />
<input type="text" class="span2" placeholder="Zip5" />
<input type="text" class="span4" placeholder="Store" />
</div>
</div>
<div class="row-fluid">
<div class="span12">
<div class="span4 offset8">
<button class="btn btn-success pull-right">Search</button>
</div>
</div>
</div>
Taken from the manual
For multiple grid inputs per line, use the .controls-row modifier class for proper spacing.
It floats the inputs to collapse white-space, sets the proper margins, and clears the float.

Resources