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

checkbox and radio spacing problem #13548

Closed
rgbskills opened this issue May 9, 2014 · 15 comments
Closed

checkbox and radio spacing problem #13548

rgbskills opened this issue May 9, 2014 · 15 comments

Comments

@rgbskills
Copy link

some spacing issues with the radio and checkbox inputs. First i thought that my markup's wrong but theirs some extra margin on them. (I was using master branch, installed bootstrap with bower), Let me know if i can give more info to help this get fixed.

@rgbskills rgbskills changed the title checkbox and radio spaing problem checkbox and radio spacing problem May 9, 2014
@rgbskills
Copy link
Author

Here is my fix:

old:
.radio, .checkbox {
display: block;
min-height: 20px;
margin-top: 10px;
margin-bottom: 10px;
}

New:
.radio, .checkbox {
height: 20px;
}

@cvrebert
Copy link
Collaborator

cvrebert commented May 9, 2014

Please post a JS Fiddle demonstrating the problem.

@cvrebert cvrebert added the css label May 9, 2014
@drakej
Copy link

drakej commented May 9, 2014

Compile bootstrap with @font-size-base set to anything besides 14px (default) and it's immediately apparent that the margin set for the input tag is arbitrary and probably got hard coded around the assumption of a 14px font size. The margin always get's set to 4px at the top which is why the radio buttons and the checkboxes don't align properly.

@rgbskills
Copy link
Author

I did use a different font, but I did not change the default typography.

@mdo
Copy link
Member

mdo commented May 11, 2014

Still, we need a jsbin or example link.

@rgbskills
Copy link
Author

Here is a jsfiddle: http://jsfiddle.net/halirgb/dWqyK/ Let me know if theirs anything else i can help with this issue.

@cvrebert
Copy link
Collaborator

Change:

    <label for="radios-0">
      <input type="radio" name="radios" id="radios-0" value="1" checked="checked">
      Option one
    </label>

To:

    <label for="radios-0">
      <input type="radio" name="radios" id="radios-0" value="1" checked="checked">
      Option one</label>

Etc.

i.e. Remove the extra linebreaks within the <label>s.

Fixed example: http://jsfiddle.net/dWqyK/3/

Not really sure why that fixes it though.

@rgbskills
Copy link
Author

I have experienced something similar with input-group's in BS 2.x.x (you head to put the input right after the input-group-addon) otherwise ther would be a 1px white space between the addon and input field, Weird,,

http://jsfiddle.net/halirgb/dWqyK/4/ The fix works, Thank you!

cvrebert referenced this issue May 14, 2014
…rounding div to the label to remove the no-click deadzone caused by negative margin
@cvrebert
Copy link
Collaborator

Reopening for investigation (and documentation if necessary). Confirmed that the spacing weirdness happens in Chrome but not in Firefox.
CC: @mdo

@cvrebert cvrebert reopened this May 15, 2014
@ItsJonQ
Copy link
Contributor

ItsJonQ commented May 22, 2014

Heya,

This is a strange issue. For what it's worth.. if you add display: block to .radio label / .checkbox label it fixes the issue in Chrome. Don't know if that's ideal though.

Hope this helps!

@CyborgMaster
Copy link

This appears to be a breaking change in master.

In 3.1.1, the less for checkbox labels was:

.radio,
.checkbox {
  display: block;
  min-height: @line-height-computed; // clear the floating input if there is no label text
  margin-top: 10px;
  margin-bottom: 10px;
  padding-left: 20px;
  label {
    display: inline;
    font-weight: normal;
    cursor: pointer;
  }
}

on master it is now:

.radio,
.checkbox {
  display: block;
  min-height: @line-height-computed; // clear the floating input if there is no label text
  margin-top: 10px;
  margin-bottom: 10px;

  label {
    padding-left: 20px;
    margin-bottom: 0;
    font-weight: normal;
    cursor: pointer;
  }
}

The crucial display: inline; was removed in master. Display inline seems to cause the label to ignore whitespace, while inline-block is counting the newlines, which is why removing the line breaks was working for @cvrebert.

I motion to put display: inline; back.

@cvrebert
Copy link
Collaborator

The display: inline was removed in a83ca38.

@CyborgMaster
Copy link

@cvrebert, are you just providing that for info, or is there a reason for the removal that I don't understand?

@cvrebert
Copy link
Collaborator

For context, to help this issue get debugged without re-breaking the older issue.

@zzullick
Copy link

This has been driving me nuts for a few days because I wasn't experiencing the same issue with the latest 3.1.1 zip package. Glad to see it wasn't only me noticing this.

How I fixed it for now:

.radio,
.checkbox {
    padding-left: 20px;
}
.radio label,
.checkbox label {
    display: inline;
    padding: 0;
}

@cvrebert cvrebert added this to the v3.2.0 milestone May 30, 2014
@mdo mdo mentioned this issue Jun 11, 2014
@mdo mdo closed this as completed in 631e04b Jun 11, 2014
stempler pushed a commit to stempler/bootstrap that referenced this issue Nov 4, 2014
…radio line-height problems that were introduced after twbs#13003
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants