html - 如何更改 iFrame "Select File"上的光标

标签 html iframe css

我正在使用 iFrame 来模拟 <input type="file"> .这是它的作用:

1 - 一个链接显示 "Choose your file" .

2 - 用户单击链接,浏览其本地计算机上的文件。

3 - 当用户选择文件时,它会自动开始上传。

这很好用。但是,我无法控制游标的类型。我将如何强制光标成为指针?

http://jsfiddle.net/4paY6/是以下代码的示例。

<html>
    <head>
        <style>
        .attach-file:hover {
            text-decoration: underline;
            cursor: pointer;
        }
        .attach-file {
            padding-left: 22px;
            background: url("{{ STATIC_URL }}images/new/attach-file.png") no-repeat 0 1px;
            color: #0BA5D9;
            position: relative;
            top: 0;
            left: 0;
        }
        form {
            float: right;
        }
        html, body {
            padding: 0;
            margin: 0;
            border: 0;
        }
        input[type="file"] {
            z-index: 999;
            opacity: 0.0; 
            line-height: 0; 
            position: absolute;
            position: fixed;
            font-size: 500px; 
            top: -100px; 
            left: -200px;

            -moz-appearance: none;
            white-space: nowrap;
            cursor: pointer;
            -moz-binding: none;
        }

        input[type="file"] > input[type="text"] {
          border-color: inherit;
          background-color: inherit;
          color: inherit;
          font-size: inherit;
          height: inherit;
        }

        /* button part of file selector */
        input[type="file"] > input[type="button"] {
            height: inherit;
            font-size: inherit;
        }
        input[type="file"]:hover {
            cursor: default;
        }
        * {
            overflow: hidden;
        }
    </style>
</head>
<body>

    <form method="post" action="." enctype="multipart/form-data" style="position: inline">
        <label style="overflow: hidden; position: relative;">
           <span class="attach-file">Attach File</a>
            <input type="file" name="attachment" />
        </label>
    </form>
</body>

当悬停在 iFrame 上时,我需要添加或更改什么才能在 Firefox 中模拟光标?

最佳答案

CSS

input[type="file"]:hover {
        cursor: default;
    }

覆盖了其他样式定义。将其移除,您将获得指针光标。

关于html - 如何更改 iFrame "Select File"上的光标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11406077/

相关文章:

html - 扩展到父 div 之外导致移动设备出现问题

javascript - HTML/CSS 自动编号标题?

iframe - YouTube iframe wmode 问题

javascript - iframe 仅在 firefox 上显示不正确?

javascript - 创建iframe中的js对象

javascript - 下拉菜单不会关闭

Javascript 图像随时间改变位置

html - Bootstrap Collapse - 无动画

html - 使 flexbox 行成为最短子元素的高度?

css - 缩小 .css 文件时创建 *.css.map 文件