我不确定为什么当鼠标悬停在按钮上时,光标没有变成指针。有些解决方案说这是因为 z-index
的问题。但是当我尝试使用 z-index
时,它仍然无效。
.upload-btn-wrapper {
position: relative;
overflow: hidden;
display: inline-block;
}
.btn {
border: 2px solid gray;
color: gray;
background-color: white;
padding: 8px 20px;
border-radius: 8px;
font-size: 20px;
font-weight: bold;
}
.upload-btn-wrapper input[type=file] {
font-size: 100px;
position: absolute;
left: 0;
top: 0;
opacity: 0;
cursor: pointer;
}
<div class="upload-btn-wrapper">
<button class="btn">Upload a file</button>
<input type="file" name="myfile" />
</div>
感谢任何帮助。
我在从这个CodePen作弊:
cursor: pointer;
属性。 - Dheeraj Kumar.upload-btn-wrapper input[type=file]::-webkit-file-upload-button {cursor: pointer; }
工作-不确定为什么。 - Alon Eitan