微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

拖动元素时如何禁用阻塞光标?

如何解决拖动元素时如何禁用阻塞光标?

我正在一个小网页中实现“拖放”功能,但是,我遇到了一个界面问题。

每当我尝试拖动 draggable 属性设置为 true 的元素时,浏览器都会在该元素旁边显示一个 blocking-icon

下面是一张有助于说明问题的图片

Blocking icon on drag attempt

有谁知道如何更改那个图标,或者它是不可解决的吗?

<!DOCTYPE html>
<html lang="en">
<head>
    <Meta charset="UTF-8">
    <title>Document</title>
    <style>
        #dropzone {
            background-color: #eee;
            border: 1px dashed #aaa;
            max-width: 200px;
            padding: 100px;
            -webkit-user-drag: auto;
        }
        .draggable {
            width: 100px;
            height: 50px;
            background-color: burlywood;
            border-radius: 10px;
            margin: 20px;
            line-height: 50px;
            text-align: center;
        }
    </style>
</head>
<body>
<div></div>
<div id="dropzone">
    <p style="text-align: center;"><b>Dropzone</b><br>Drag anything over here</p>
</div>
<div class="draggable" id="o1" draggable="true">Object 1</div>
<div class="draggable" id="o2" draggable="true">Object 2</div>
<script>
    window.ondragstart = function(e) {
        e.dataTransfer.setData('text/plain',e.target.id);
    }
    
    var dropzone = document.querySelector('#dropzone');

    dropzone.ondragover = function(e) {
        e.preventDefault();
    }
    dropzone.ondrop = function(e) {
        // this.innerHTML = '';
        this.appendChild(document.getElementById(e.dataTransfer.getData('text/plain')));
    }
</script>
</body>
</html>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。