28

After last firefox-update some of css3-code has been broken... Example (jsfiddle).

  • In chromium: normal, chome
  • In firefox 34: firefox 34, bad

Is it bug? Or normal working? What do i need to change to fix it? Why #flex don't resize properly?

HTML:

<div id="outer">
    <div id="flex">
        <label>123</label>
        <input type="text" value="some text" />
    </div>
</div>  

CSS:

#outer { display: flex; }

#flex {
    display: flex;
    border: 1px solid green;
    outline: 1px solid red;
}

label { flex: 0 0 80px; }
5
  • 3
    input { min-width: 1px; } fix problem. -moz-min-content... Commented Dec 11, 2014 at 14:43
  • Thank you for asking this. I see this behaviour in our system maybe since version 33 or 32. Please mention the box-sizing model you use because I think the problem has to do with it. Commented Dec 14, 2014 at 8:11
  • @AshrafSabry, content-box Commented Dec 15, 2014 at 13:30
  • possible duplicate of How can I get FF 33.x Flexbox behavior in FF 34.x? Commented May 17, 2015 at 16:44
  • Is there a reason jsfiddle.net/944tL115/20 cannot work? Just set the width attribute directly? Commented Sep 25, 2015 at 7:13

5 Answers 5

49

Fix:

input { min-width: 1px; }

For vertical direction - min-height;

Sign up to request clarification or add additional context in comments.

3 Comments

Chrome also recently aligned their flexbox spec so this should be applied on chrome as well.
This is still the answer in 2019 (FF 66.0.2)
5

There is a bug in Firefox 34. One of the elements is not playing nicely as a flex child, and the input seems to be too wide. This extra width is not taken into account by the flex containers green border.


This can be confirmed as a bug because in Firefox 33.1 (and Chrome / IE) there is no problem with your example:

Your Example Firefox 33.1

Working Fine

Your Example Firefox 34.0.5 — The input width is miscalculated by the flex container and the input itself cannot be given a smaller width.

Not working


As a workaround, we can set a width on the label; this width is recognised by the container and the bug is prevented in Firefox 34. In order to be used only in Firefox, we can set the width using the -moz- prefix with calc:

label {
    width: -moz-calc(80px);
}

(Obviously previous versions of Firefox will also recognise this width)

Bug Workaround Example

Using inline-flex

From your example, it looks like you want to use inline-flex in order to contain the width of the form to the width of its children. I have used this and removed the extra div that is no longer needed. There is a big difference in input widths per browser (this is consistent with the example in your question).

Firefox 33

Old Firefox Screenshot

Firefox 34

Firefox Example

Chrome

Chrome Screenshot

IE11

IE Example

form {
  display: inline-flex;
  border: solid 1px green;
  outline: 1px solid red;
}
label {
  flex: 0 0 80px;
  width: -moz-calc(80px);
}
<form>
  <label>123</label>
  <input type="text" value="some text" />
</form>

4 Comments

Did Mozilla acknowledge this as a bug? Is it mentioned on their bug tracker? My flexbox UI was working well on Firefox until version 32 or 33 or 34 (not sure because I was using the developer edition which is two versions ahead the release version)
also interested in @AshrafSabry's question above; can anyone confirm that this is indeed a bug?
@AshrafSabry Its due to a spec change: developer.mozilla.org/en-US/Firefox/Releases/34/…
@sergio91pt - Good find. So not a bug at all and I don't think my answer is that useful anymore. Could you add your comment underneath the accepted answer where it will be seen? I'll edit it in to that answer later and delete this post.
5

variant with

min-width: 0

also works

Comments

3

What you could do is, subtract 80px from 100% and set that a width for input. Additionally, add box-sizing: border-box to prevent overflow.

form {
  display: flex;
}
#flex {
  display: flex;
  border: 1px solid green;
  outline: 1px solid red;
}
label {
  display: flex;
  flex: 0 0 80px;
}
input {
  width: calc(100% - 80px);
  box-sizing: border-box;
}
<form>
  <div id="flex">
    <label>123</label>
    <input type="text" value="some text" />
  </div>
</form>

2 Comments

added to comment (below answer) strange "solution": input { min-width: 1px; }... working. Bug or not bug? :)
@faiwer - Great! And yea strange solution. I wouldn't say its a bug, its just how different browsers render the elements.
0

Display: flex; only needs to be on the container that needs to be flexible, not the inner elements. Here's the updated CSS, if you need a specific width, you can set that on form {}.

CSS

form {}

#flex {
    display: flex;
    border: 1px solid green;
    outline: 1px solid red;
}

#flex > * {
    flex: 1;
}

label {}

input {}

1 Comment

you lost problem :) label without flex-basis, form without display: flex. my minimal jsfiddle codes had it. current version without display: flex for label (mistake) - jsfiddle.net/944tL115/4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.