Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Styling input type="file" with a box shadow

Tags:

html

css

forms

I am using javascript to add a red glow using CSS box-shadow to form fields that are incorrectly filled. I am running into a problem with my file input field, in Firefox the glow extends around the browse button and I am also unable to remove the default border.

Is there a way to achieve this with CSS?

Thanks.

Here is an example -

enter image description here

HTML

<input type='file' id='userfile' name='userfile' maxlength='80' class='form-input'/>

CSS class being assigned

.field-error { -webkit-box-shadow: 1px 1px 5px 5px #ff0000; -moz-box-shadow: 1px 1px 5px 5px #ff0000; box-shadow: 1px 1px 5px 5px #ff0000; border: none; }
like image 518
Tom Avatar asked May 16 '26 04:05

Tom


1 Answers

As far as I know the "Browse" button is completely inaccessible to CSS manipulation. You need some tricks to overcome this issue. I recommend you take a look at this article:

  • http://www.quirksmode.org/dom/inputfile.html

Or use jQuery alternative:

  • http://www.appelsiini.net/projects/filestyle
like image 114
Qorbani Avatar answered May 18 '26 16:05

Qorbani



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!