Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Within .form-inline, label isn't on the same line as its .input-group #20752

Closed
mihaistoie opened this issue Sep 20, 2016 · 11 comments
Closed

Within .form-inline, label isn't on the same line as its .input-group #20752

mihaistoie opened this issue Sep 20, 2016 · 11 comments

Comments

@mihaistoie
Copy link

mihaistoie commented Sep 20, 2016

Inline forms: Labels of input groups are placed above input fields

inlineforms

Html:

<form class="form-inline">
  <div class="form-group">
    <label for="exampleInputAmount">Amount </label>
    <div class="input-group">
      <div class="input-group-addon">$</div>
      <input type="text" class="form-control" id="exampleInputAmount" placeholder="Amount">
    </div>
  </div>
  <div class="form-group">
    <label for="exampleInputAmount2">Amount </label>
      <input type="text" class="form-control" id="exampleInputAmount2" placeholder="Amount">
    </div>
  </div>
</form>

https://jsbin.com/jimoli/edit?html,output

OS: win7 64, browsers Firfox/IE/Chrome

@Ap110460
Copy link

Not android

@cpeuterbaugh
Copy link

+1

@Rosenny08
Copy link

Hello mihaistoie. Your only problem is that you are missing an end tag and one end div is in a bad position. Try this:

 <form class="form-inline">
            <div class="form-group">
                <label for="exampleInputAmount">Amount </label>
                <div class="input-group">
                    <div class="input-group-addon">$</div>
                    <input type="text" class="form-control" id="exampleInputAmount" placeholder="Amount">
                </div>

                <div class="form-group">
                    <label for="exampleInputAmount2">Amount </label>
                    <input type="text" class="form-control" id="exampleInputAmount2" placeholder="Amount">
                </div>
            </div>
          </form> 

@cpeuterbaugh
Copy link

cpeuterbaugh commented Sep 21, 2016

@Rosenny08 , I ran the code you posted on a blank Bootply with Bootstrap 4.0-alpha and it is not working. Is this something that has been corrected since the 4.0-alpha version that is used on Bootply was put in?

@mihaistoie
Copy link
Author

Source of problem:

_input-group.scss

.input-group {
    position: relative;
    width: 100%;    // --> this line
    display: table; 
    border-collapse: separate;
}

Normally the solution is to add :

.form-inline .input-group {
    width: auto;   
}

@Rosenny08
Copy link

@cpeuterbaugh I ran the code in a blank file too and it's working for me.
input
I don't know if it's not compatible with the latest Bootstrap Cause I'm using the previews version.

@Rosenny08
Copy link

@mihaistoie your answer is right. Also you can give that parameter to the form-control. And add more:

.form-control {
  height: 10px;
  width: auto;
  display: inline;
  padding: 10px 12px;
}

@mihaistoie
Copy link
Author

@Rosenny08 : You are using bootstrap 3.x (bold labels). The issue is for bootstrap 4 alpha-4 not for 3.x.

@Rosenny08
Copy link

Ahhhhh. Oh God. My excuses then.

@cpeuterbaugh
Copy link

@mihaistoie Thank you so much! And @Rosenny08, thanks for the help as well.

@heikojansen
Copy link
Contributor

In _input-group.scss, lines 5-7 read:

.input-group {
    position: relative;
    width: 100%;

Then in _forms.scss we have lines 322ff (within the rules for .form-inline):

.input-group {
    display: inline-table;
    vertical-align: middle;

    .input-group-addon,
    .input-group-btn,
    .form-control {
        width: auto;
    }
}

So as @mihaistoie said, the problem could be fixed by adding width: auto; to the .form-inline .input-group properties at line 325.

In Bootstrap 3 this apparently wasn´t needed because .input-group did not have a default width: 100%; property - but I don´t know Bootstrap well enough to understand why that has changed in v4.

@cvrebert cvrebert changed the title V4 Inline forms with input-group, labels wrong positioning Within .form-inline, label isn't on the same line as its .input-group Sep 22, 2016
@mdo mdo added this to the v4.0.0-alpha.5 milestone Oct 9, 2016
mdo added a commit that referenced this issue Oct 9, 2016
Overrides the default width: 100% with an auto. Fixes #20752.
@mdo mdo closed this as completed in #20868 Oct 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants