Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

custom input file in bootstrap 4 not show button

When I use Custom input file in bootstrap 4, don't change my input and don't show browse button.

file-browser

<label class="custom-file">
    <input type="file" id="Image" class="custom-file-input">
    <span class="custom-file-control"></span>
</label>

.custom-file

position: relative;
display: inline-block;
max-width: 100%;
height: 2.5rem;
cursor: pointer;

.custom-file-input

min-width: 14rem;
max-width: 100%;
margin: 0;
filter: alpha(opacity=0);
opacity: 0;

.custom-file-control

position: absolute;
top: 0;
left: 0;
right: 0;
z-index: 5;
height: 2.5rem;
padding: .5rem 1rem;
line-height: 1.5;
color: #555;
user-select: none;
background-color: #fff;
border: 1px solid #ddd;
border-radius: .25rem;

enter image description here

like image 470
Soheil Alizadeh Avatar asked Mar 03 '17 08:03

Soheil Alizadeh


People also ask

How to add custom file input in Bootstrap 4?

You can simply add the .form-control-file to your <input> element for a basic file input. For the custom file input, you need to add the .custom-file-input class to the <input> element and the .custom-file-label class to the <label> element. This a basic Bootstrap 4 file input example:

How do I upload multiple files in Bootstrap 5?

Bootstrap 5/4 mainly offers two File Input types (Basic and Custom Inputs) that you can use to upload files and images simultaneously for single and multiple files. The basic file input can be created by just adding a .form-control-file class with the < input > element.

How to show hidden file names in Bootstrap?

Use the Bootstrap custom file input classes. Add the plugin to your project, and add this code in your script file on the page. $ (document).ready (function () { bsCustomFileInput.init () }) When you have multiple files, an idea is to show only the first file and the number of the hidden file names.

How do I create a checkbox in Bootstrap 4?

Bootstrap 4 comes with customized form elements, that are meant to replace browser defaults: To create a custom checkbox, wrap a container element, like <div>, with a class of .custom-control and .custom-checkbox around the checkbox.


1 Answers

As far as i've checked - you need to insert the :before and :after pseudoelements - then it works.

.custom-file-control:before{
  content: "Browse";
}
.custom-file-control:after{
  content: "Add files..";
}

http://codepen.io/powaznypowazny/pen/jBqzgR

like image 115
Kuba Wojtach Avatar answered Nov 09 '22 10:11

Kuba Wojtach