I want to use the label for trick to create custom file input:
input[type="file"] {
width: 0.1px;
height: 0.1px;
opacity: 0;
overflow: hidden;
position: absolute;
z-index: -1;
}
section {
padding: 30px;
border: 1px solid lightgray;
width: 200px;
margin: 100px;
}
label {
display: block;
}
<section>
<label for="test">
<input type="file" id="test">
<button>Click me</button>
</label>
</section>
But when I click the button inside the label it doesn't not open the file popup, only when I click outside it's working. How can I do this?