Home > Article > Web Front-end > How Can I Customize the Twitter Bootstrap File Upload Button Appearance?
Despite the absence of a dedicated style for the file upload button in Twitter Bootstrap, there are several methods to enhance its appearance.
One solution, applicable for Bootstrap versions 3, 4, and 5, leverages the HTML5 hidden attribute to create a functional file input control that resembles a button:
<label class="btn btn-default"> Browse <input type="file" hidden> </label>
This approach relies on the hidden attribute, which Bootstrap 4 emulates with CSS for compatibility. For Bootstrap 3, this additional CSS may be required:
[hidden] { display: none !important; }
Legacy Approach for Old IE:
IE8 and below require a different HTML/CSS structure:
<span class="btn btn-default btn-file"> Browse <input type="file"> </span>
.btn-file { /* ... */ } .btn-file input[type=file] { /* ... */ }
Notes:
For more details and examples, refer to the blog post by Abeautifulsite: https://www.abeautifulsite.net/posts/whipping-file-inputs-into-shape-with-bootstrap-3/
The above is the detailed content of How Can I Customize the Twitter Bootstrap File Upload Button Appearance?. For more information, please follow other related articles on the PHP Chinese website!