I have a label for a file-upload button, which is styled. If I click the button, it isn't opening the file dialogue.
My html code looks like this:
<div >
<input type="file" >
<label for="file">Choose file...</label>
</div>
My css code looks like this:
.file
{
opacity: 0;
width: 0.1px;
height: 0.1px;
position: absolute;
}
.file-input label
{
display: block;
position: relative;
width: 200px;
height: 50px;
border-radius: 25px;
background: linear-gradient(40deg, #ff6ec4, #7873f5);
box-shadow: 0 4px 7px rgba(0, 0, 0, 0.4);
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-weight: bold;
cursor: pointer;
transition: transform .2s ease-out;
}
I tried to click the button, but it didn't open the file dialogue.
CodePudding user response:
Can you set style for this class '.file'
.file {
width: 200px;
height: 50px;
z-index: 1;
cursor: pointer;
}