Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox 4 file input width bug?

3I'm changing the width of a file input HTML tag:

<input type="file" id="newFilename" name="Filename">
input[type="file"] {width:380px !important}

In Firefox 3, Chrome and Safari it works perfectly.

In Firefox 4 I cant get it to work. The width remain the same!

Demo: http://jsfiddle.net/LwzW9/1/

Checking with Firebug I noticed that the size of the <input> changes, but I don't really see the changes: (see image)

enter image description here

Any ideas? Is this a known bug?

Thanks.

like image 925
Jonathan Avatar asked Apr 06 '11 12:04

Jonathan


Video Answer


2 Answers

I had the same problem when using uniform.js, this kind of solves the problem:

<input type="file" size="X">

or

$('input[type="file"]').attr('size', 'X');

where X is a number of characters that you define. You should also have the correct width in your CSS for safety in other browsers.

Fiddle: http://jsfiddle.net/EfntV/

like image 118
martnu Avatar answered Nov 10 '22 03:11

martnu


I notice that you have

width: 380px !important; //line 94

This would override the value of #newFilename {width:280px}

Note I'm not 100% sure about how it works since you're using a much more specific CSS selector to change the width. Would need some sample to look at

like image 40
JohnP Avatar answered Nov 10 '22 02:11

JohnP