1

I am trying to style some buttons and I am trying to both limit the width of my buttons and have some horizontal padding, so there is some space between the text and the border.

I have therefore applied the following CSS to my class:

.class1 {
    border: 1px solid;
    padding: 0 20px;
    max-width: 100px;
    white-space: nowrap;
    overflow:hidden;
}

See this jsFiddle for an example.

My problem is that when the text is too long, Firefox (latest version: 22) does not respect the left padding anymore and make the text stick to the left border, as one can see in the middle button in this screenshot:

Result in Firefox

When Chrome still respect the left padding:

enter image description here

Is there some way I can make Firefox behaves the same way as Chrome and IE10 here?

Some things I have determined:

  • IE10 behaves the same way as Chrome, so I think it's a Firefox problem.
  • If I replace buttons with spans, it works, but of course I need buttons. I would like to avoid using <a> if it is not necessary, since it is not semantically correct.
  • Changing the box-sizing property or resetting -moz-focus-inner, does not help.
4

1 回答 1

2

试试这个“黑客”:

.class1::-moz-focus-inner {

    padding: 0px 20px;

}

您必须在 Firefox 中删除填充以防止双重填充。

@-moz-document url-prefix() {

    .class1 {

        padding: 0px;

    }

}

(它在 FF 22 中对我有用,jsFiddle

于 2013-07-22T17:38:06.127 回答