14

All the CSS attributes apply to the <input type='file'/> don't work on FF, but work on most other browsers.

Just can't even set the width. Any solution? No JS please.

3 Answers 3

20

Have you set the size attribute?

<input type="file" name="datafile" size="40">

Firefox doesn't support setting the size via CSS.

3
  • but attribute 'size' is measured in characters (font & font size dependent), and it's hard to measure
    – jondinham
    Nov 25, 2011 at 14:12
  • 1
    It's still the only way. Other than that, what you are trying to do isn't possible as FF doesn't support it. Nov 25, 2011 at 14:14
  • 3
    This does not work, after selecting a very long file name, it still exceeds the boundaries of the input field. Apr 23, 2014 at 21:11
13

I wouldn't have a clue if anyone still finds this thread, but just in case...

input[type="file"] {
max-width: 100%;
}

...worked for me. Cuts the overlap off, but at least it doesn't over- or underlap anymore

1
  • This is the best answer.
    – Adam
    Jan 12, 2017 at 23:37
1

What if

<input type="file" name="file_to_upload" id="file_to_upload" style="max-width:75px;"> 

For me works in FF 37.0.1. But possibly in older versions does not work

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.