Home >Web Front-end >CSS Tutorial >How Can I Customize File Input Appearance with CSS3 and JavaScript?
Styling Input Files with CSS3 and JavaScript
While it's possible to style the default "input file" element using CSS3, the customization options are limited. To fully customize the appearance of the file input or trigger the browsing window with an alternative element, here's how you can achieve it using HTML, CSS3, and JavaScript:
Customizing with jQuery
<div>
#file { display: none; }
var wrapper = $('<div/>').css({height: 0, width: 0, 'overflow': 'hidden'}); var fileInput = $(':file').wrap(wrapper); fileInput.change(function() { $(this).closest('#file').text($(this).val()); }); $('#file').click(function() { fileInput.click(); }).show();
Result:
A custom file input element that can be customized through CSS and triggers the file browsing window when clicked.
The above is the detailed content of How Can I Customize File Input Appearance with CSS3 and JavaScript?. For more information, please follow other related articles on the PHP Chinese website!