CSS中no-drop和not-allowed有何区别?

9

我很惊讶地发现CSS中“no-drop”和“not-allowed”的光标样式本质上是相同的。那么,为什么我们需要它们?

2个回答

8

虽然它们在大多数系统上可能会产生相同的效果,但它们在语义上是不同的,允许浏览器和/或系统为每种情况实现不同的图形。 no-drop 意味着该元素不实现拖放 API,而 not-allowed 是一个通用术语,表示某些操作在元素上没有启用。

div {
  padding: 5px;
  margin: 5px;
}

pre {
  display: inline-block;
  background-color: #DDDDDD;
}

.no-drop {
  background-color: #DD22DD;
  cursor: no-drop;
}

.not-allowed {
  background-color: #DDDD22;
  cursor: not-allowed;
}
<div class="no-drop">This area displays the <pre>no-drop</pre> cursor.</div>

<div class="not-allowed">This area displays the <pre>not-allowed</pre> cursor.</div>


2

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接