如果HTML/CSS中只显示背景,我想隐藏光标。但由于某些原因,它不能正常工作,它在背景上显示光标。以下是HTML:
<html>
<head>
<style>
body {
background:url('img.png') #000000 top left no-repeat;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
vertical-align:top;
text-align:center;
z-index: -1;
margin:0;
padding:0;
cursor:none
}
</style>
</head>
<body scroll="no" cz-shortcut-listen="true">
</body></html>
我认为从您的标记,您正在寻找隐藏光标外面的图像。除了需要游标的部分之外,还可以使用CSS属性
下面的示例将光标隐藏在图像外部:
<style type="text/css">
.hide-cursor { cursor:none; }
.show-cursor { cursor:auto }
</style>
<html>
<body class="hide-cursor">
<h1>These contents get no cursor visibility</h1>
<p>These contents get no cursor visibility</p>
<div class="show-cursor">
<img src="https://image.shutterstock.com/image-photo/bright-spring-view-cameo-island-260nw-1048185397.jpg" />
</div>
<h1>These contents get no cursor visibility</h1>
<p>These contents get no cursor visibility</p>
</body>
</html>
如果您看起来像是在整个页面中隐藏光标,除了您需要的光标,请使用适用于整个页面的CSS:
html * {cursor:none}