How to style the input type="file"
button.
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
- Adding a timeout to a render function in ReactJS
As JGuo and CorySimmons mentioned, you can use the clickable behaviour of a stylable label, hiding the less flexible file input element.
follow these steps then you can create custom styles for your file upload form:
1.) this is the simple html form(please read the html comments i have written here below)
2.) then use this simple script to pass the click event to file input tag.
now you can use any type of a styling without worrying how to change default styles. i know this very well, because i have been trying to change the default styles for month and a half. believe me it's very hard because different browsers have different upload input tag. So use this one to build your custom file upload forms.Here is the full AUTOMATED UPLOAD code.
enjoy!
Have a Nice Day,
I am able to do it with pure CSS using below code. I have used bootstrap and font-awesome.
VISIBILITY:hidden TRICK
I usually go for the
visibility:hidden
trickthis is my styled button
this is the input type=file button. Note the
visibility:hidden
rulethis is the JavaScript bit to glue them together. It works
Here's a simple css only solution, that creates a consistent target area, and lets you style your faux elements however you like.
The basic idea is this:
Here's the jsfiddle: http://jsfiddle.net/gwwar/nFLKU/
A really clever solution using jQuery that works in all older browsers as well as in the new ones, I found here. It takes care of all the styling and click() problems, using the actual file browse button. I made a plain javascript version: fiddle The solution is as simple as genius: make the file-input invisible, and use a piece of code to place it under the mousecursor.