This question already has an answer here:
- Styling an input type=“file” button 39 answers
Simple question... How do I change the cursor type on a file input type?
I've tried the following:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<style>
input[type="file"] {
cursor: pointer;
}
</style>
</head>
<body>
<input type="file">
</body>
</html>
For some reason, it won't play ball.
It works differently in different browsers. I guess it's because the file input type is quite special.
What browser/version do you use?
I know that IE6 does not support to specify the type in the style.
How it works in the different browsers
IE7+
Works perfectly.
FireFox
Issue is fixed, so now it works perfectly. See bug report on this issue.
In version 3.5 it did not work at all.
Chrome and Safari (identical behavior)
Uses arrow over the button, but your defined cursor over the rest.
Opera
Works perfectly.
Note that there are several workarounds using different techniques that will come around this problem. The answer by BjarkeCK is one elegant solution that I like, and it works on all major browsers.
I made the following:
for li:
for input:
As it was mentioned before, cursor becomes "pointer" on the whole input, excluding the button. In most browsers the button is on the left side or on the right side. Ok! Lets give the input a huge width and show only the middle... Button will be hidden. And clickable is the whole input.
That works for me.
cursor:pointer
does not work on input file just because of the default button. No special reason here. You need to remove its appearance via this code, pay attention withfont-size:0
.It works perpectly on Chrome, Firefox and IE.
Try using:
See if that works. I've had to put pointer + hand in mine to make it work in FF/Chrome/etc. Also, I'm not sure if it matters but I don't think there are quotes around 'file' in the css.
I made a solution with jquery here: http://jsfiddle.net/gKVKm/36/
Take a look here to see whats going on:
It works for me in Opera, Safari, IE, Chrome and Firefox.
Chrome was giving me this problem too. I tried to set all sorts of CSS selectors, but nothing seemed to work well. However, I did find a solution by using the FORM element.
I tested this in Chrome and FF, not ie, but I hope this helps. jsfiddle http://jsfiddle.net/aressler38/L5r8L/1/