是否可以使用CSS或Javascript将光标隐藏在网页中? [英] Is it possible to hide the cursor in a webpage using CSS or Javascript?

查看:106
本文介绍了是否可以使用CSS或Javascript将光标隐藏在网页中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在显示要在大厅内显示信息的网页时隐藏光标。它不必是互动的。我尝试了cursor属性和一个透明的光标图像,但我没有使它工作。

I want to hide the cursor when showing a webpage that is meant to display information in a building hall. It doesn't have to be interactive at all. I tried with the cursor property and a transparent cursor image but I didn't make it work.

有人知道这可以做吗?我想这可以被认为是一个安全威胁的用户,不知道他在哪里点击,所以我不是很乐观...谢谢!

Does anybody know if this can be done? I suppose this can be thought as a security threat for a user that can't know where he is clicking on, so I'm not very optimistic... Thank you!

推荐答案

使用CSS:

selector { cursor: none; }

例如:

<div class="nocursor">
 <!-- some stuff -->
</div>
<style type="text/css">
    .nocursor { cursor:none; }
</style>

要在Javascript中的元素上设置此属性,可以使用 style 属性:

To set this on an element in Javascript, you can use the style property:

<div id="nocursor"><!-- some stuff --></div>
<script type="text/javascript">
    document.getElementById('nocursor').style.cursor = 'none';
</script>

如果您要在全身设置:

<script type="text/javascript">
    document.body.style.cursor = 'none';
</script>

但是确保你真的想隐藏光标。它可以真的烦人。

Make sure you really want to hide the cursor, though. It can really annoy people.

这篇关于是否可以使用CSS或Javascript将光标隐藏在网页中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆