Home > Web Front-end > CSS Tutorial > How Can I Customize the Twitter Bootstrap File Upload Button Appearance?

How Can I Customize the Twitter Bootstrap File Upload Button Appearance?

Linda Hamilton
Release: 2024-11-26 09:25:12
Original
793 people have browsed it

How Can I Customize the Twitter Bootstrap File Upload Button Appearance?

Customizing the Twitter Bootstrap File Upload Button

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>
Copy after login

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;
}
Copy after login

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>
Copy after login
.btn-file {
  /* ... */
}

.btn-file input[type=file] {
  /* ... */
}
Copy after login

Notes:

  • Old IE does not allow file input triggering upon label click.
  • The CSS compensates by extending the file input to match the span and then hiding it.

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template