Global form control styles not working.
From the getbootstrap.com site:
Individual form controls automatically receive some global styling. All textual
<input>, <textarea>, and <select>elements with .form-control are set to width: 100%; by default. Wrap labels and controls in .form-group for optimum spacing.
But a simple form control receives 0 styling. It looks like an input box. When I add .form-control, it gets styled in a bootstrap-py way, but is now 100% width, which is stupid. I now have to go through my entire site either adding widths, or wrapping them in grid containers to get simple rounded corners and glow border?
which is stupid.
Well, you might think that, and then you might also step back and think that it makes a lot of sense since many forms these days are built within some kind of a container or two-column/gridded layout. And in that situation, it makes a lot of sense.
I now have to go through my entire site either adding widths, or wrapping them in grid containers to get simple rounded corners and glow border?
What you're describing here is a false dichotomy—it is not either or. Yes, we now require a class on forms. Yes, if you want easy horizontal sizing you should use the grid columns for medium to long length forms. That said, you can do a number of other things, two of which come to mind:
- Use the
.form-controlstyles as a mixin and via Less apply them to all yourinput[type="text"]and other inputs in one fell swoop. Thus, no need for classes. - Override the default Bootstrap
widthwith your own setting, something that works pretty well for you, at a global level. Something like.form-control { width: 200px; }.
Those two combined could also be super useful I imagine.
The intent is that extending, customizing, and building things are all massively simpler. It might seem a bit more complicated because we're using classes, but there are some easily identifiable benefits (performance, ease of customization, consistent behavior across the library, etc).
Hope that helps.
Sorry, I was a bit rattled by the attempted upgrade at the amount of work I assumed I needed to do due to the vast changes in BS3. My original report, that some global styles are applied to form controls still appears to be valid - no styles are applied to plain form controls. This may be a documenation bug.
On Tue, Jul 30, 2013 at 12:21 AM, Mark Otto [email protected]:
which is stupid.
Well, you might think that, and then you might also step back and think that it makes a lot of sense since many forms these days are built within some kind of a container or two-column/gridded layout. And in that situation, it makes a lot of sense.
I now have to go through my entire site either adding widths, or wrapping them in grid containers to get simple rounded corners and glow border?
What you're describing here is a false dichotomy—it is not either or. Yes, we now require a class on forms. Yes, if you want easy horizontal sizing you should use the grid columns for medium to long length forms. That said, you can do a number of other things, two of which come to mind:
- Use the .form-control styles as a mixin and via Less apply them to all your input[type="text"] and other inputs in one fell swoop. Thus, no need for classes.
- Override the default Bootstrap width with your own setting, something that works pretty well for you, at a global level. Something like .form-control { width: 200px; }.
Those two combined could also be super useful I imagine.
The intent is that extending, customizing, and building things are all massively simpler. It might seem a bit more complicated because we're using classes, but there are some easily identifiable benefits (performance, ease of customization, consistent behavior across the library, etc).
Hope that helps.
— Reply to this email directly or view it on GitHubhttps://github.com/twbs/bootstrap/issues/8824#issuecomment-21770219 .
I agree that this is a documentation bug rather than a code bug. I don't see anything in the upgrade page indicating that all form controls will need to have a class added to get the same styling as in 2.x. This should probably be added as a bullet in "Additional Notes" section of the Migration section.
FWIW, I think this is probably the correct behavior as styling unclassed input elements had many surprising side-effects when integrating with a pre-existing site. Though I had already gone through it all to fix them, before upgrading to BS3.
not documented in Migration section. but documented in css -> forms
Individual form controls automatically receive some global styling. All textual
<input>,<textarea>, and<select>elements with.form-controlare set towidth: 100%;by default. Wrap labels and controls in.form-groupfor optimum spacing.
fchiumeo: the global styling those elements receive is very minimal. Rounded corners and focus highlighting, for example, are not included. Basic browser styling for input elements is pretty raw in most browsers and does not look anything like BS2. I think this should be mentioned in the Migration section.
@nikolawannabe Wanna open a pull request? :smile:
@cvrebert Happily! But where is the source for getbootstrap.com located? I didn't find it in this repo.
@nikolawannabe It uses the HTML in this repo. You wanna modify https://github.com/twbs/bootstrap/blob/master/getting-started.html
I too got caught by this problem. After reading this part of documentation:
Individual form controls automatically receive some global styling. All textual
<input>,<textarea>, and<select>elements with .form-control are set to width: 100%; by default. Wrap labels and controls in .form-group for optimum spacing.
... I created a form with no additional CSS styling, and I can see no 100% width is applied to the inputs by default. Either a documentation or CSS bug.
@meglio
All textual
<input>,<textarea>, and<select>elements with.form-controlare set to width: 100%; by default.
The answer is clearly stated in the docs. You must add the form-control class in order to get the 100% width applied