javascript 光标:指针不适用于输入类型文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13249103/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 18:11:10  来源:igfitidea点击:

Cursor:pointer not working on input type file

javascriptjqueryhtmlcss

提问by Hyman

Possible Duplicate:
Change cursor type on input type=“file”

可能的重复:
在输入类型=“文件”上更改光标类型

This is my jsfiddle:

这是我的 jsfiddle:

http://jsfiddle.net/3zNMK/

http://jsfiddle.net/3zNMK/

This class already has a cursor but not working:

这个类已经有一个游标但不工作:

.file
{
    cursor:pointer;
}

I want that even though a hover is made on textbox inside input type file, it should change to hand icon. But it is not working.

我希望即使在输入类型文件内的文本框上悬停,它也应该更改为手形图标。但它不起作用。

Any way to change this behavior?

有什么办法可以改变这种行为?

回答by Sowmya

Try some manipulation like this

尝试一些这样的操作

HTML

HTML

<span class="file-wrapper">
  <input type="file" name="photo" id="photo" />
  <span class="button">Choose a File</span>
</span>

? CSS

? CSS

.file-wrapper {
  cursor: pointer;
  display: inline-block;
  overflow: hidden;
  position: relative;
}
.file-wrapper input {
  cursor: pointer;
  font-size: 100px;
  filter: alpha(opacity=1);
  -moz-opacity: 0.01;
  opacity: 0.01;
  position: absolute;
  right: 0;
  top: 0;
}
.file-wrapper .button {
  background: #333;
  -moz-border-radius: 5px;
  -webkit-border-radius: 5px;
  border-radius: 5px;
  color: #fff;
  cursor: pointer;
  display: inline-block;
  font-size: 11px;
  font-weight: bold;
  margin-right: 5px;
  padding: 4px 18px;
  text-transform: uppercase;
}
?

DEMO

演示

回答by Weacked

You used cursor:hand;on your fiddle, this is outdated.

你用cursor:hand;在你的小提琴上,这已经过时了。

if you use cursor:pointer;, the hand cursor will appear when you hover your input.

如果您使用cursor:pointer;,则在您将输入悬停时会出现手形光标。

回答by Ahmad

cursor:handis understood by few old browser, like IE6. User cursor:pointerinstead

cursor:hand很少有旧浏览器可以理解,例如 IE6。cursor:pointer代替用户